/**
 * @(#)BinaryTestString.java
 *
 *
 * @author 
 * @version 1.00 2009/11/25
 */
import java.io.*;

public class main {  

	static String[] input = new String[5];
	static String[] initiation = new String[16];
	static int count = 0;

	public static void main(String[] args) throws IOException {

    	 try{
 			FileInputStream stream = new FileInputStream("DATA3.txt ");
    		DataInputStream in = new DataInputStream(stream);
 	     	BufferedReader reader = new BufferedReader(new InputStreamReader(in));
    		String strLine;
 	
    		for (int i = 0; i < 5; i++)   {
 				input[i] = reader.readLine();
    		}
 
	    	in.close();
    	}
    
    	catch (Exception exceptions){ 
      		System.err.println("Error: " + exceptions.getMessage());
    	}
    	
    	initiation();
    	check();
    }

	public static void initiation() {
		for (int a = 0; a < 2; a++) {
			String tem = a + "";
			for (int b = 0; b < 2; b++){
				String tem1 = b + "";
				for (int c = 0; c < 2; c++){
					String tem2 = c + "";
					for (int d = 0; d < 2; d++){
						String tem3 = d + "";
						initiation[count] = tem + tem1 + tem2 + tem3;
						count += 1;
					}
				}
			}
		}
	}
	
	public static void check() throws IOException {
		FileWriter fstream = new FileWriter("OUT3.txt ");
        PrintWriter out = new PrintWriter(fstream);
        	
		for (int a = 0; a < 5; a++) {
			for (int b = 0; b < 16; b++) {
				try {
					String temp = initiation[b] + initiation[b];
					if (temp.indexOf(input[a]) < 0) {
					out.println(initiation[b]);
					}
				}
				catch (Exception exceptions) {
					break;
				}
			}
		}
		out.close();
	}
}
	
