public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        StringBuilder s = new StringBuilder(16);
        String [][] a = new String[4][4];
        String [][] b = new String[4][4];
        for (int i = 0 ; i < 4 ; i++)
                a[i]=in.next().split("");
        for (int i = 0 ; i < 4 ; i++)
                b[i]=in.next().split("");
        for (int k = 0 ; k < 4 ; k++){
            for (int i = 0 ; i < 4 ; i++)
                for (int j = 0 ; j < 4 ; j++)
                    s.append(("X".equals(a[i][j]))?b[i][j]:"");
            a = convert(a);
        }
        out.println(s);
        out.flush();
    }