base = 37 #mod = 2305843009213693951 #2**61 - 1 制限時間に余裕があり衝突したらこっちを使う #これでTLEしたら #mod2 = 10**9 + 7とかで複数でチェック mod = 10**9 + 7 class RollingHash(): def __init__(self, s, base, mod): self.mod = mod l = len(s) self.pw = pw = [1]*(l+1) self.h = h = [0]*(l+1) v = 0 for i in range(l): #小文字のみ h[i+1] = v = (v * base + s[i]) % mod #大文字のみ or 大文字と小文字のみ #h[i+1] = v = (v * base + ord(s[i])-64) % mod #通常 #h[i+1] = v = (v * base + ord(s[i])) % mod v = 1 for i in range(l): pw[i+1] = v = v * base % mod #[l,r) def get(self, l, r): return (self.h[r] - self.h[l] * self.pw[r-l]) % self.mod import sys #sys.setrecursionlimit(500000) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def TI(): return tuple(map(int,sys.stdin.readline().rstrip().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip()) #for i, pi in enumerate(p): from collections import defaultdict,deque import bisect import itertools dic = defaultdict(int) d = deque() N,K = MI() A = LI() S = RollingHash(A,base,mod) #https://aotamasaki.hatenablog.com/entry/meguru_bisect #arg桁 def is_ok(arg,x,y): if arg == 0: return True if arg == N: return False if arg <= x and arg <= y: return True if arg <= x: X = S.get(0,arg) else: X = (S.get(0,x)*S.pw[arg-x]+S.get(x+1,arg+1))%mod if arg <= y: Y = S.get(0,arg) else: Y = (S.get(0,y)*S.pw[arg-y]+S.get(y+1,arg+1))%mod if X == Y: return True else: return False def meguru_bisect(ng, ok,s,t): ''' 初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す まずis_okを定義すべし ng ok は とり得る最小の値-1 とり得る最大の値+1 最大最小が逆の場合はよしなにひっくり返す ''' while (abs(ok - ng) > 1): mid = (ok + ng) // 2 if is_ok(mid,s,t): ok = mid else: ng = mid return ok def cmp(x,y): h = meguru_bisect(N,0,x,y) if h == N-1: return 0 if x > h: f = A[h] else: f = A[h+1] if y > h: ff = A[h] else: ff = A[h+1] if f < ff: return -1 elif f == ff: return 0 else: return 1 D = list(range(N)) from functools import cmp_to_key p = sorted(D, key = cmp_to_key(cmp)) x = p[K - 1] ans = A[:x] + A[x + 1:] print(*ans)