base = 37 #こっちはなんでもよい、modはいじれない mod = 2305843009213693951 #2**61 - 1 制限時間に余裕があり衝突したらこっちを使う ss = 2**31 sr = 2**30 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 vv = 1 for i in range(l): ad = v % ss au = v // ss mid = au*base midu = mid//sr midd = mid%sr #小文字のみ #h[i+1] = v = (midu+midd*ss+ad*base + ord(s[i])-96) % mod #大文字のみ or 大文字と小文字のみ #h[i+1] = v = (midu+midd*ss+ad*base + ord(s[i])-64) % mod #通常 #h[i+1] = v = (midu+midd*ss+ad*base + ord(s[i])+1) % mod #自然数 h[i+1] = v = (midu+midd*ss+ad*base + s[i]) % mod ad = vv % ss au = vv // ss mid = au*base midu = mid//sr midd = mid%sr pw[i+1] = vv = (midu+midd*ss+ad*base)% mod #[l,r) def get(self, l, r): a = self.h[l] b = self.pw[r-l] au = a // ss ad = a % ss bu = b // ss bd = b % ss mid = au*bd + ad*bu midu = mid//sr midd = mid%sr return (self.h[r] - au*bu*2-midu-midd*ss-ad*bd) % 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[N-1-x])%mod+S.get(x+1,arg+1))%mod if arg < y: Y = S.get(0,arg) else: Y = ((S.get(0,y)*S.pw[N-1-y])%mod+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)