import java.util.Scanner;
public class PBM2a {
private int[][] bits;
private int rows,columns;
PBM2a() throws ImageFormatException{
Scanner sc =
new Scanner(System.in);
if (!sc.next().equals("P1"))
throw new ImageFormatException("Format error");
columns=sc.nextInt();
rows=sc.nextInt();
bits=new int[rows][columns];
for (int i=0; i< rows; i++){
String line="";
while (line.length() < columns) {
line += sc.next();
}
for (int j=0; j<columns; j++)
bits[i][j]=line.charAt(j)-'0';
}
}
public String toString(){
String result="";
for (int i=0; i< rows; i++){
long rowStart=System.nanoTime();
for (int j=0; j<columns; j++){
if (bits[i][j]==1)
result += "*";
else
result += " ";
}
result +="\n";
// System.err.println("completed row "+i+" in time " + (System.nanoTime() - rowStart)/1e6+"ms");
}
return result;
}
public static void main(String [] args) throws ImageFormatException{
long startTime = System.nanoTime();
PBM2a pbm = new PBM2a();
long readTime = System.nanoTime();
System.err.println("time to read " + (readTime-startTime)/1e6 + "ms");
String str = pbm.toString();
long stringTime = System.nanoTime();
System.err.println("time to string " + (stringTime-readTime)/1e6 + "ms");
System.out.println(str);
long wroteTime = System.nanoTime();
System.err.println("time to write " + (wroteTime-stringTime)/1e6 + "ms");
}
}
//@keywords: array, 2D array, bitmap, file, image processing