import java.io.*;
import java.util.*;


// images stored a[x][y]

public class Compress {
  
  public static String restExp=null;
  
  public static void main(String[] argv) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

    while((restExp = in.readLine())!=null){
      char[][] image = getNext();

      for(int x=0;x<image.length+2;x++)
	System.out.print('-');
      System.out.println();
      for(int y=0;y<image[0].length;y++){
	System.out.print('|');
	for(int x=0;x<image.length;x++)
	  System.out.print(image[x][y]);
	System.out.println('|');
      }
      for(int x=0;x<image.length+2;x++)
	System.out.print('-');
      System.out.println();
    }

      
  }

  public static char[][] getNext(){
    String thisExp = restExp.substring(0,2);
    restExp = restExp.substring(2);
    char[][] a;

    if(thisExp.equals("00")){
      a = new char[1][1];
      a[0][0] = 'X';
      return a;
    }
    if(thisExp.equals("11")){
      a = new char[1][1];
      a[0][0] = ' ';
      return a;
    }
    
    if(thisExp.equals("10")){
      char[][] l = getNext();
      char[][] r = getNext();

      int scale = findScale(l[0].length, r[0].length);
      if(l[0].length<scale)
	l=magnify(l,scale/l[0].length);
      if(r[0].length<scale)
	r=magnify(r,scale/r[0].length);
      
      a = new char[l.length+r.length][l[0].length];

      for(int y=0;y<l[0].length;y++){
	for(int x=0;x<l.length;x++)
	  a[x][y] = l[x][y];
	for(int x=0;x<r.length;x++)
	  a[x+l.length][y] = r[x][y];
      }

      return a;
    }

    if(thisExp.equals("01")){
      char[][] t = getNext();
      char[][] b = getNext();

      int scale = findScale(t.length, b.length);
      /*System.out.println(
			 b.length+" "+b[0].length+" "+
			 t.length+" "+t[0].length+" "+scale);*/
      if(t.length<scale)
	t=magnify(t,scale/t.length);
      if(b.length<scale)
	b=magnify(b,scale/b.length);
      
      a = new char[t.length][t[0].length+b[0].length];

      for(int y=0;y<t[0].length;y++){
	for(int x=0;x<t.length;x++)
	  a[x][y] = t[x][y];
      }
      /*System.out.println(a.length+" "+a[0].length+" "+
			 b.length+" "+b[0].length+" "+
			 t.length+" "+t[0].length);*/
      for(int y=0;y<b[0].length;y++){
	for(int x=0;x<b.length;x++)
	  a[x][y+t[0].length] = b[x][y];
      }
      

      return a;
    }

    System.err.println("unknown pattern "+thisExp);
    System.exit(1);

    return null;
  }


       



  public static int findScale(int a, int b){
    // stupid factoring alg
    int scale = 2;
    
    if(a==b)
      return 1;

    while(scale%a != 0 ||
	  scale%b != 0)
      scale++;

    return scale;
  }
    

  public static char[][] magnify(char[][] a, int scale){
    int ax = a.length;
    int ay = a[0].length;
    
    char[][] b = new char[ax*scale][ay*scale];

    int bx=0;
    int by=0;

    for(int y=0;y<ay;y++){
      for(int ym = 0 ; ym < scale ; ym++){
	for(int x=0;x<ax;x++){
	  for(int xm = 0 ; xm < scale ; xm++){
	    b[x*scale+xm][y*scale+ym] = a[x][y];
	  }
	}
      }
    }

    return b;
  }


	
}
