/*
Converts P3 ppms to P6 ppms using input/output redirection.
*/

#include <stdio.h>

int main(void){
	char header[10];
	scanf("%s\n",header);

	int width, height, depth;
	scanf("%d %d %d\n",&width,&height,&depth);
	
	printf("P6\n%d %d %d\n",width, height, depth);	

	int i, j;
	for (i = 0; i < height; i++){
		for (j = 0; j < width; j++){
			int r, g, b;
			scanf("%d %d %d", &r, &g, &b);
			printf("%c%c%c",r,g,b);
		}
	}
}
