#include <bits/stdc++.h>
#define LOCAL
using std::to_string;
auto to_string(std::string s) -> std::string {
  return '"' + s + '"';
}
auto to_string(char c) -> std::string {
  return "'" + std::string{c} + "'";
}
auto to_string(const char* s) -> std::string {
  return to_string((std::string) s);
}
auto to_string(bool b) -> std::string {
  return (b ? "true" : "false");
}
template <typename T, typename U>
auto to_string(std::pair<T, U> p) -> std::string {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <size_t N>
auto to_string(std::bitset<N> bs) -> std::string {
  std::string res{};
  for (size_t i = 0; i < N; i++)
    res.insert(res.begin(), bs.test(i) ? '1' : '0');
  return res;
}
template <typename T>
auto to_string(T v) -> std::string {
  bool flg = false;
  std::string res = "{";
  for (auto const&x : v) {
    if (flg) res += ", ";
    else flg = true;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  std::cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template <typename T>
auto make_vector(size_t sz, T t) {
  return std::vector<T>(sz, t);
}
template <size_t N, typename T, typename U>
auto make_higher_vector(size_t sz, U u) {
  static_assert(N == 1, "");
  return make_vector(sz, T(u));
}
template <size_t N, typename T>
auto make_higher_vector(size_t sz) {
  static_assert(N == 1, "");
  return std::vector<T>(sz);
}
template <size_t N, typename T, typename... Args>
auto make_higher_vector(size_t a, Args... args) {
  return make_vector(a, make_higher_vector<N - 1, T>(args...));
}
template <typename T, typename Size_t>
auto& at(T& t, Size_t i) {
  return t.at(i);
}
template <typename T, typename Size_t, typename... Args>
auto& at(T& t, Size_t i, Args... args) {
  return at(t.at(i), args...);
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; long long k; std::cin >> n >> k;
  std::vector<int> a(n);
  for (auto& x : a) {
    std::cin >> x;
    x--;
  }
  a.insert(a.begin(), -1);
  constexpr int max = 2e5;
  auto m = make_higher_vector<2, int>(max, 0, 0);
  for (int i = 1; i <= n; i++) {
    m.at(a.at(i)).push_back(i);
    m.at(a.at(i)).push_back(n + i);
  }
  std::vector<int> next(n, -1);
  for (auto& v : m) {
    std::sort(v.begin(), v.end());
    int sz = v.size();
    for (int i = 0; i < sz - 1; i++) {
      auto crr = v.at(i) - 1;
      if (crr >= n) break;
      next.at(crr) = v.at(i + 1);
    }
  }
  assert(std::none_of(next.begin(), next.end(), [](auto x){return x == -1;}));
  auto simulate = [&] (int start) {
    auto now = std::vector<int>{};
    for (int i = start; i < n;) {
      if (next.at(i) <= n) {
        i = next.at(i);
      } else {
        now.push_back(a.at(++i));
      }
    }
    return now;
  };
  auto calc[[maybe_unused]] = [&] (int k) {
    int now_ind  = 0;
    while (k > 1) {
      now_ind = next.at(now_ind);
      if (now_ind >= n) {
        k--;
        now_ind -= n;
      }
    }
    assert(k == 1 || (k == 0 && now_ind == 0));
    return simulate(
      k == 0
      ? n
      : now_ind
    );
  };
  auto calc_cycle[[maybe_unused]] = [&] {
    int now_cycle = 0;
    int now_ind   = 0;
    while (now_ind != n) {
      now_ind = next.at(now_ind);
      if (now_ind > n) {
        now_cycle++;
        now_ind -= n;
      }
    }
    return now_cycle + 1;
  };
  k %= calc_cycle();
  auto ans = calc(k);
  for (auto& x : ans) x++;
  int sz = ans.size();
  for (int i = 0; i < sz; i++) {
    std::cout << (i > 0 ? " " : "") << ans.at(i);
  }
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 15856