#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

loadppm(char *name){
    FILE *f;
    int done,width,height,x,y;
    int gray;
    unsigned char r,g,b,s[256];


    f=fopen(name,"r");  
    fgets(s,256,f);
    s[strlen(s)-1]=0;
    if (!strcmp(s,"P6"))
   {
       done=1;
       while (done)
      {
          fgets(s,256,f);
          s[strlen(s)-1]=0;
          if (s[0]!='#')      
         {
             done=0;
             sscanf(s,"%i %i",&width,&height);
             fgets(s,256,f);
             s[strlen(s)-1]=0;
             for (y=0;y<height;y++)
            {
                for (x=0;x<width;x++)
               {
                   fread(&r,1,1,f);
                   fread(&g,1,1,f);
                   fread(&b,1,1,f);
		   gray=(int)(r+g+b)/3;
		   gray=gray>>5;
		   if (gray<=0){
			printf("W");
		   }
		   if (gray==1){
			printf("X");
		   }
		   if (gray==2){
			printf("V");
		   }
		   if (gray==3){
			printf("I");
		   }
		   if (gray==4){
			printf("!");
		   }
		   if (gray==5){
			printf(":");
		   }
		   if (gray==6){
			printf(".");
		   }
		   if (gray>=7){
			printf(" ");
		   }
                }
		printf("\n");
             }
         }
      }
   }
    fclose(f);
}

main(int argc,char **argv)
{
    loadppm(argv[1]);
}



