#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (n, k) = (v[0] as usize, v[1]);
    let a = read_vec::<usize>();
    let mut poses = HashMap::new();
    for i in 0..n {
        poses.entry(a[i]).or_insert(vec![]).push(i);
    }

    let mut cur_pointer = 0;
    let mut cycle = 1i64;
    loop {
        let mut next_pointer_idx = poses[&a[cur_pointer]].upper_bound(&cur_pointer);
        if next_pointer_idx == poses[&a[cur_pointer]].len() {
            cycle += 1;
            next_pointer_idx = 0;
        }
        cur_pointer = poses[&a[cur_pointer]][next_pointer_idx] + 1;
        if cur_pointer == a.len() {
            break;
        }
    }
    debug!(cycle);
    let k = k % cycle;
    if k == 0 {
        println!("");
        return;
    }

    let mut cur_pointer = 0;
    let mut cycle_count = 0;
    while cycle_count < k - 1 {
        let mut next_pointer_idx = poses[&a[cur_pointer]].upper_bound(&cur_pointer);
        if next_pointer_idx == poses[&a[cur_pointer]].len() {
            cycle_count += 1;
            next_pointer_idx = 0;
        }
        cur_pointer = poses[&a[cur_pointer]][next_pointer_idx] + 1;
    }
    debug!(cur_pointer);
    let start = cur_pointer;
    if start == n {
        println!("");
    } else {
        // simulate final cycle
        let mut ans = vec![];
        // ans.push(a[cur_pointer]);
        // cur_pointer += 1;

        while cur_pointer != n {
            let next_pointer_idx = poses[&a[cur_pointer]].upper_bound(&cur_pointer);
            if next_pointer_idx == poses[&a[cur_pointer]].len() {
                ans.push(a[cur_pointer]);
                cur_pointer += 1;
            } else {
                cur_pointer = poses[&a[cur_pointer]][next_pointer_idx] + 1;
            }
        }

        print_array(&ans);
    }
}

fn print_array<T: std::string::ToString>(array: &Vec<T>) {
    println!(
        "{}",
        array
            .iter()
            .map(|ref x| x.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

use std::cmp::Ordering;

pub trait BinarySearch<T> {
    fn lower_bound(&self, &T) -> usize;
    fn upper_bound(&self, &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }

    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}


Measured memory_bytes: 34212