Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

from itertools import combinations
n = int(input())
s = []
p = 0
for _ in range(n):
	i, j = map(int, input().split())
	s.append([i, j])

hate = []
for i in range(len(s)):
	for j in range(i+1, n):
		if s[i][0]*s[j][0] + s[i][1]*s[j][1] == 0:
			hate.append([i, j])

def comb(li):
	count = 0
	for l in li:
		if len(l) == 1:
			count += 1
		else:
			flag = 0
			for pr in list(combinations(l, 2)):
				if list(pr) in hate: flag = 1
			if flag == 0:
				count += 1
	return count

for i in range(1, n+1):
	l = list(combinations(range(0, n), i))
	p += comb(l)
print(p % 1000000007)

### FIXED CODE ###

import numpy as np
dic = dict()
mod = 10 ** 9 + 7
p = 0

def reg(a, b):
	if a < 0 or (a == 0 and b < 0):
		a, b = -a, -b
	if b > 0:
		return 0, a, b
	else:
		return 1, -b, a

n = int(input())
for _ in range(n):
	a, b = map(int, input().split())
	if a == 0 and b == 0:
		p += 1
		continue
	ab = np.gcd(a, b)
	a, b = a//ab, b//ab
	idx, a, b = reg(a, b)
	k = (a, b)
	if k not in dic.keys():
		dic[k] = [0, 0]
	dic[k][idx] += 1

not_p = 1
for k in dic.keys():
	a, b = k
	pp, pm = dic[k]
	not_p *= (pow(2, pp, mod) + pow(2, pm, mod) - 1) % mod
	not_p %= mod

print((p + not_p -1) % mod)
### BUGGY CODE ###

n=int(input())
g=list(map(int,input().split()))
l=[0]*(max(g)+2)
for i in g:
  for j in range(max(0,i-1),min(i+2,max(g)+1)):
    l[j]+=1
print(max(l))

### FIXED CODE ###

n=int(input())
g=list(map(int,input().split()))
f=max(g)
l=[0]*(f+2)
for i in g:
  for j in range(max(0,i-1),min(i+2,f+1)):
    l[j]+=1
print(max(l))
### BUGGY CODE ###

N = int(input())
S = input()

ans = 0
for i in range(1000):
    t = "{:0=3}".format(i)
    p = 0
    for j in range(N):
        if S[j] == t[p]:
            p += 1
        if p == 3:
            break
    if p == 3:
        ans += 1

print(ans)


### FIXED CODE ###

N = int(input())
S = input()

ans = 0
for i in range(1000):
    t = "{:0=3}".format(i)
    p = 0
    for j in range(N):
        if S[j] == t[p]:
            p += 1
        if p == 3:
            break
    if p == 3:
        ans += 1

print(ans)
### BUGGY CODE ###

def DP(N,M):
    dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
    dp_sum = [[0 for _ in range(N+1)] for _ in range(N+1)]
    dp[0][0] = 1
    for j in range(N+1):
        dp_sum[0][j] = 1
    #dp[i][j]:i個の項で和がj
    #dp_sum[i][j]:dp[i][0]+...+dp[i][j]
    for i in range(1,N+1):
        for j in range(1,N+1):
            dp[i][j] = (dp_sum[i-1][j-1] - dp_sum[i-1][i-1] + dp[i-1][i-1]) % M
            dp_sum[i][j] = (dp_sum[i][j-1] + dp[i][j]) % M

    return dp

def main():
    N,K = map(int,input().split())
    M = 10**9+7

    dp = DP(N,M)

    comb = 1
    for i in range(1,K+1):
        comb *= (N - K + 2 - i)
        comb *= pow(i,M-2,M)
        comb %= M
        if i > N - K + 1:
            comb = 0
        print((comb * dp[i][K]) % M)

if __name__ == "__main__":
    main()


### FIXED CODE ###

def DP(N,M):
    dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
    dp_sum = [[0 for _ in range(N+1)] for _ in range(N+1)]
    dp[0][0] = 1
    for j in range(N+1):
        dp_sum[0][j] = 1
    #dp[i][j]:i個の項で和がj
    #dp_sum[i][j]:dp[i][0]+...+dp[i][j]
    for i in range(1,N+1):
        for j in range(1,N+1):
            dp[i][j] = (dp_sum[i-1][j-1] - dp_sum[i-1][i-1] + dp[i-1][i-1]) % M
            dp_sum[i][j] = (dp_sum[i][j-1] + dp[i][j]) % M

    return dp

def main():
    N,K = map(int,input().split())
    M = 10**9+7

    dp = DP(N,M)

    comb = 1
    for i in range(1,K+1):
        comb *= (N - K + 2 - i)
        comb *= pow(i,M-2,M)
        comb %= M
        if i > N - K + 1:
            comb = 0
        print((comb * dp[i][K]) % M)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


def func(a, b, c):
    return a * a + b * b + c * c + a * b + b * c + c * a


n = inp()
limit = int(math.sqrt(n)) + 1
for x in range(1, n + 1):
    ans = 0
    for i in range(1, limit):
        for j in range(i, limit):
            for k in range(j, limit):
                if func(i, j, k) == x:
                    if len(set([i, j, k])) == 1:
                        ans += 1
                    elif len(set([i, j, k])) == 2:
                        ans += 3
                    elif len(set([i, j, k])) == 3:
                        ans += 6
    print(ans)


### FIXED CODE ###

import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


def func(a, b, c):
    return a * a + b * b + c * c + a * b + b * c + c * a


n = inp()
limit = int(math.sqrt(n)) + 1
ans = [0] * n
for i in range(1, limit):
    for j in range(i, limit):
        for k in range(j, limit):
            x = func(i, j, k) - 1
            if x < n:
                if len(set([i, j, k])) == 1:
                    ans[x] += 1
                elif len(set([i, j, k])) == 2:
                    ans[x] += 3
                elif len(set([i, j, k])) == 3:
                    ans[x] += 6
for i in ans:
    print(i)
### BUGGY CODE ###

import itertools
n = int(input())
an = list(map(int, input().split()))
diff = itertools.combinations(list(range(1, n+1)), 2)
li = itertools.combinations(an, 2)
ans = 0
for d, l in zip(diff, li):
    if abs(d[0]-d[1]) == l[0]+l[1]:
        ans += 1
print(ans)


### FIXED CODE ###

from collections import defaultdict
N = int(input())
A = [int(n) for n in input().split()]
record = defaultdict(int)
count = 0
for i in range(len(A)):
    cur = i-A[i]
    count += record[cur]
    record[i+A[i]] += 1
print(count)
### BUGGY CODE ###

a=int(input())
b=input().split(' ')
m=0
s=1
while m<a:
    s=s*int(b[m])
    m=m+1
if s>10**18:
    print(-1)
else:
    print(s)


### FIXED CODE ###

a=int(input())
b=input().split(' ')
m=0
s=1
i=0
o=0
while i<a:
    if int(b[i])==0:
        print(0)
        o=o+1
    i=i+1
while m<a and o==0:
    s=s*int(b[m])
    m=m+1
    if s>10**18 and o==0:
        print(-1)
        o=o+1
        break

if o==0:
    print(s)
### BUGGY CODE ###

N, K = map(int, input().split())
x = []
y = []
for i in range(N):
    xi, yi = map(int, input().split())
    x.append(xi)
    y.append(yi)
x_sorted = sorted(x)
y_sorted = sorted(y)


def included(xmin, xmax, ymin, ymax):
    count = 0
    for i in range(N):
        if xmin <= x[i] <= xmax and ymin <= y[i] <= ymax:
            count += 1
    return count


ans = 4 * 10 ** 18
for i in range(N):
    for j in range(i + 1, N):
        for k in range(N):
            for l in range(k + 1, N):
                num = included(x_sorted[i], x_sorted[j], y_sorted[k], y_sorted[l])
                if num > K:
                    break
                elif num == K:
                    s = (x_sorted[j] - x_sorted[i]) * (y_sorted[l] - y_sorted[k])
                    if ans > s:
                        ans = s
                else:
                    continue
print(ans)


### FIXED CODE ###

N, K = map(int, input().split())
x = []
y = []
for i in range(N):
    xi, yi = map(int, input().split())
    x.append(xi)
    y.append(yi)
x_sorted = sorted(x)
y_sorted = sorted(y)

S_l = [[0 for i in range(N)] for j in range(N)]
S_rs = [[0 for i in range(N)] for j in range(N)]
S_ts = [[0 for i in range(N)] for j in range(N)]
S_s = [[0 for i in range(N)] for j in range(N)]
for i in range(N):
    for j in range(N):
        count_l = 0
        count_rs = 0
        count_ts = 0
        count_s = 0
        for k in range(N):
            if -10 ** 9 <= x[k] <= x_sorted[i] and -10 ** 9 <= y[k] <= y_sorted[j]:
                count_l += 1
            if -10 ** 9 <= x[k] < x_sorted[i] and -10 ** 9 <= y[k] <= y_sorted[j]:
                count_rs += 1
            if -10 ** 9 <= x[k] <= x_sorted[i] and -10 ** 9 <= y[k] < y_sorted[j]:
                count_ts += 1
            if -10 ** 9 <= x[k] < x_sorted[i] and -10 ** 9 <= y[k] < y_sorted[j]:
                count_s += 1
        S_l[i][j] = count_l
        S_rs[i][j] = count_rs
        S_ts[i][j] = count_ts
        S_s[i][j] = count_s


def included(i, j, k, l):
    return S_l[j][l] - S_rs[i][l] - S_ts[j][k] + S_s[i][k]

ans = 4 * 10 ** 18
for i in range(N):
    for j in range(i + 1, N):
        for k in range(N):
            for l in range(k + 1, N):
                num = included(i, j, k, l)
                if num > K:
                    break
                elif num == K:
                    s = (x_sorted[j] - x_sorted[i]) * (y_sorted[l] - y_sorted[k])
                    if ans > s:
                        ans = s
                else:
                    continue
print(ans)
### BUGGY CODE ###

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort(reverse = True, key = lambda x:x[1])
ans = 0
for i in range(1, M + 1):
  for j in range(len(AB)):
    if AB[j][0] <= i:
      ans += AB.pop(j)[1]
      break

print(ans)

### FIXED CODE ###

from heapq import heappush, heappop

N, M = map(int, input().split())
jobs = [[] for _ in range(M)]

for i in range(N):
  ab = list(map(int, input().split()))
  #Ai > M の仕事はいらない
  if ab[0] <= M:
    jobs[ab[0] - 1].append(ab[1])

#最終日はAi=1の仕事のみ選べる。その前の日はAi<=2, ...
#終わりから考えればよさそう
hq = []
ans = 0
for i in range(M):
  for b in jobs[i]:
    heappush(hq, -1 * b)
  if len(hq) > 0:
    m = -1 * heappop(hq)
    ans += m

print(ans)
### BUGGY CODE ###

import heapq
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M, L = map(int, input().split())
adj = [set() for _ in range(N)]
roads = [[-1]*N for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    if c <= L:  # 移動出来ない経路は消す
        roads[a-1][b-1] = c
        roads[b-1][a-1] = c
        adj[a-1].add(b-1)
        adj[b-1].add(a-1)


def calc_ans(start, end):
    dist = [[-1]*(N+1) for _ in range(N)]  # dist[i][j] iまで給油j会で行った時の残りの最大値
    dist[start][0] = L
    Q = [[0, start]]  # (給油回数、current node)
    while Q:
        kyuyu, cur_node = heapq.heappop(Q)
        if cur_node == end:
            continue
        remain = dist[cur_node][kyuyu]
        assert remain != -1
        for next in adj[cur_node]:
            # 給油せずにいく
            to_next = roads[cur_node][next]
            if dist[next][kyuyu] == -1:
                if to_next <= remain:  # 給油なしでいける
                    dist[next][kyuyu] = remain-to_next
                    heapq.heappush(Q, [kyuyu, next])
            else:
                cur_cost = dist[next][kyuyu]
                if to_next-remain > cur_cost:
                    dist[next][kyuyu] = to_next-cur_cost
                    Q.append([kyuyu, next])
                    heapq.heappush(Q, [kyuyu, next])
            #　給油していく
            if kyuyu+1 <= N and dist[next][kyuyu+1] == -1:
                dist[next][kyuyu+1] = L-to_next
                heapq.heappush(Q, [kyuyu+1, next])
            elif kyuyu+1 <= N:
                cur_cost = dist[next][kyuyu+1]
                if L-to_next > cur_cost:
                    dist[next][kyuyu] = L-to_next
                    heapq.heappush(Q, [kyuyu+1, next])

    for i in range(N):
        if dist[end][i] >= 0:
            return i
    return -1


Q = int(input())
query = [list(map(lambda x:int(x)-1, input().split())) for _ in range(Q)]

for s, t in query:
    print(calc_ans(s, t))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def WF(mat, N):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                mat[i][j] = min(mat[i][j], mat[i][k]+mat[k][j])
    return mat


N, M, L = map(int, input().split())
roads = [[float('inf')]*N for _ in [0]*N]
kyuyu = [[float('inf')]*N for _ in [0]*N]
for _ in range(M):
    a, b, c = map(int, input().split())
    roads[a-1][b-1] = c
    roads[b-1][a-1] = c

roads = WF(roads, N)
for i in range(N):
    for j in range(i+1, N):
        if roads[i][j] <= L:
            kyuyu[i][j] = 1
            kyuyu[j][i] = 1
kyuyu = WF(kyuyu, N)
Q = int(input())
for _ in range(Q):
    s, t = map(lambda x: int(x)-1, input().split())
    dist = kyuyu[s][t]
    if dist == float('inf'):
        print(-1)
    else:
        print(dist-1)
### BUGGY CODE ###

import sys
readline = sys.stdin.readline

def main():

	#s = tuple(input())
	s = input()
	length = len(s)

	dp = [[0]*13 for _ in range(length+1)]
	MOD = 10**9+7
	if s[-1] == '?':
		for i in range(10):
			dp[1][i] = 1
	else:
		dp[1][int(s[-1])] = 1

	for i in range(1,length):
		if s[-i-1] != '?':
			num = (int(s[-i-1]) * (10**i)) % 13
			for j in range(13):
				dp[i+1][j] = dp[i][(13-num+j)%13]
				dp[i+1][j] %= MOD
		else:
			num = (10**i) % 13
			a = 0
			for j in range(10):
				for k in range(13):
					dp[i+1][k] += dp[i][(13-a+k)%13]
					dp[i+1][k] %= MOD
				a += num

	print(dp[-1][5] % MOD)

if __name__ == '__main__':
	main()

### FIXED CODE ###

INF = 10 ** 9 + 7

S = input()
# dp[i][j]はうしろからi桁を13で割った余りがjであるものの個数
dp = [[0] * 13 for _ in range(len(S) + 1)]
dp[0][0] = 1
mul = 1

for i in range(len(S)):
    x = S[-(i + 1)]
    if x == "?":
        for k in range(10):
            for j in range(13):
                dp[i + 1][(mul * k + j) % 13] += dp[i][j]
                dp[i + 1][(mul * k + j) % 13] %= INF
    else:
        k = int(x)
        for j in range(13):
            dp[i + 1][(mul * k + j) % 13] += dp[i][j]
            dp[i + 1][(mul * k + j) % 13] %= INF
    mul = mul * 10 % 13  # 計算量削減のためここで13で割っている

print(dp[len(S)][5])
### BUGGY CODE ###

s = input()
q = int(input())
for _ in range(q):
  d = list(input().split())
  if len(d)==1:
    s = s[::-1]
  else:
    if d[1]=='1':
      s = d[2] + s
    else:
      s += d[2]
print(s)

### FIXED CODE ###

from collections import deque
s = input()
q = int(input())
r = False
S = deque(s)
for _ in range(q):
  d = list(input().split())
  if len(d)==1:
    r = ~r
  else:
    if (d[1]=='1' and ~r) or (d[1]=='2' and r):
      S.appendleft(d[2])
    else:
      S.append(d[2])
s = ''.join(S)
if r:
  s = s[::-1]
print(s)
### BUGGY CODE ###

import sys
#import copy
import numpy as np
#import itertools
#import collections
#from collections import deque
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix

sys.setrecursionlimit(10**6)
readline = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

def main():
    N = int(readline())
    S = np.array(list(read().rstrip()), np.int8)

    #S = np.array(list(readline()))
    #print(S)

    R = np.sum(S == ord('R'))
    G = np.sum(S == ord('G'))
    B = np.sum(S == ord('B'))

    ans = R*G*B

    for i in range(N-2):
        for j in range(i+1, N-1):
            k = 2 * j - i
            if k >= N:
                break
            if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                ans -= 1

    print(ans)
    #print('end')


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
#import copy
#import numpy as np
#import itertools
import collections
#from collections import deque
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read
count = collections.Counter

def main():
    N = int(readline())
    S = input()

    values = list(count(S).values())
    if len(values) < 3:
        print(0)
        return
    
    ans = values[0] * values[1] * values[2]

    for i in range(N-2):
        for j in range(i+1, N-1):
            k = 2 * j - i
            if k >= N:
                break
            if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                ans -= 1

    print(ans)
    #print('end')


if __name__ == "__main__":
    main()
### BUGGY CODE ###


class Point():
  def __init__(self, x, y):
    self.x = x
    self.y = y
  
  def __str__(self):
    # return f"Point(x={self.x}, y={self.y})"
    return "Point(x=" + str(self.x) + "y=" + str(self.y) + ")"

  def __repr__(self):
    return self.__str__()

def parse():
  H, W = map(int, input().split(" "))
  grid = []
  for h in range(H):
    grid.append(list(input()))
  return H, W, grid

def print_grid(grid):
  H = len(grid)
  print("grid:")
  for y in range(H):
    print(grid[y])

def is_all_black(grid):
  H = len(grid)
  W = len(grid[0])
  for y in range(H):
    for x in range(W):
      if grid[y][x] == ".": return False
  return True

def main():
  H, W, grid = parse()
  # print(H, W, grid)

  vecs = [Point(0, -1), Point(0, 1), Point(-1, 0), Point(1, 0)]
  
  # 初期の黒色の場所を追加
  black_points = []
  for y in range(H):
    for x in range(W):
      if grid[y][x] == "#":
        black_points.append(Point(x, y))
  # print(black_points)

  ans = 0
  while not is_all_black(grid):
    next_black_points = []
    for black_point in black_points:
      # print("black_point:", black_point)
      for vec in vecs:
        target_point = Point(black_point.x + vec.x, black_point.y + vec.y)
        if target_point.x < 0: continue
        if target_point.y < 0: continue
        if target_point.x >= W: continue
        if target_point.y >= H: continue
        if grid[target_point.y][target_point.x] == "#": continue
        grid[target_point.y][target_point.x] = "#"
        next_black_points.append(target_point)
    black_points = next_black_points
    ans += 1

    # print("next_black_points:", next_black_points)
    # print_grid(grid)
    # input()
  
  print(ans)

if __name__ == "__main__":
  main()

### FIXED CODE ###


import numpy as np

def parse():
  H, W = map(int, input().split(" "))
  grid = [list(input()) for y in range(H)]
  return H, W, grid

def print_grid(grid):
  H = len(grid)
  print("grid:")
  for line in grid:
    for c in line:
      print(c, end="")
    print("")

def main():
  H, W, grid = parse()
  # print(H, W)
  # print_grid(grid)

  # visited = [[W * H if grid[y][x] == "." else 0 for x in range(W)] for y in range(H)]
  visited = np.zeros((H, W), int)
  for y in range(H):
    # visited.append([])
    for x in range(W):
      if grid[y][x] == ".":
        visited[y][x] = H * W

  for y in range(1, H):  # ↓
    # 要素ごとの処理
    # print(visited)
    visited[y][:] = np.minimum(visited[y][:], visited[y - 1][:] + 1)
    # print(visited)
    # input()
    # print(visited[y])
    # exit(0)

  for y in range(H - 2, -1, -1):
    visited[y, :] = np.minimum(visited[y, :], visited[y + 1][:] + 1)

  for x in range(1, W):
    visited[:, x] = np.minimum(visited[:, x], visited[:, x - 1] + 1)

  for x in range(W - 2, -1, -1):
    visited[:, x] = np.minimum(visited[:, x], visited[:, x + 1] + 1)

  # print(visited)
  # exit(0)

  # max_len = 0
  # for y in range(H):
  #   max_val = max(visited[y])
  #   max_len = max_len if max_len > max_val else max_val
  # print(max_len)
  print(np.max(visited))

if __name__ == "__main__":
  main()
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
tar = 1
for i in range(N):
    tar *= A[i]

if tar > 10 ** 18:
    print(-1)
else:
    print(tar)


### FIXED CODE ###


import sys
N = int(input())
A = list(map(int, input().split()))
A.sort()
tar = 1
for i in A:
    tar *= i
    if tar > 10 ** 18:
        print('-1')
        sys.exit()

print(tar)
### BUGGY CODE ###

# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n,k = [int(i) for i in readline().split()]
a = [int(i) for i in readline().split()]

memo = dict()
res = [-1]*(2*n)
for i,c in enumerate(a*2):
    if c in memo: res[memo[c]] = i+1
    memo[c] = i


res2 = res[:n]

"""
def dfs(i):
    if res2[i] < n: res2[i] = dfs(res2[i])
    return res2[i]

for i in range(n): dfs(i)
"""

for i in range(n-1,-1,-1):
    if res2[i] < n: res2[i] = res2[res2[i]]

cycle = [0]
offset = 0
now = res2[0]-n

while now != 0:
    if now == n:
        offset += 1
        break
    else:
        cycle.append(now)
        now = res2[now]-n


#print(cycle,offset)

l = len(cycle)
k-=1
k %= (l+offset)

#print("k =",k)

if k != l: ans = p = cycle[k]
else: ans = p = n+1
while p <= n:
    ans = p
    p = res[p]
#    print(ans,p)

if ans >= n: exit()
else:
    s = []
    for i in range(ans,n):
        if a[i] not in s:
            s.append(a[i])
        else:
            while a[i] in s: s.pop()
    
print(" ".join(map(str,s)))




### FIXED CODE ###

# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n,k = [int(i) for i in readline().split()]
a = [int(i) for i in readline().split()]

memo = dict()
res = [0]*(2*n)
for i,c in enumerate(a*2):
    if c in memo: res[memo[c]] = i+1
    memo[c] = i

#print(res)

res2 = res[:n]

for i in range(n-1,-1,-1):
    if res2[i] < n:
        res2[i] = res2[res2[i]]

cycle = [0]
offset = 0
now = res2[0]-n

while now != 0:
    if now == n:
        offset = 1
        break
    else:
        cycle.append(now)
        now = res2[now]-n

#print(res2)
#print(cycle,offset)

l = len(cycle)
k-=1
k %= (l+offset)

#print("k =",k)

if k != l: ans = cycle[k]
else: exit()
while res[ans] < n:
    ans = res[ans]

"""
if k != l: ans = p = cycle[k]
else: ans = p = n+1
while p <= n:
    ans = p
    p = res[p]
#    print(ans,p)
"""


if ans >= n: exit()
else:
    s = []
    ss = set()
    for i in range(ans,n):
        if a[i] in ss:
            while a[i] in ss:
                c = s.pop()
                ss.remove(c)
        else:
            s.append(a[i])
            ss.add(a[i])
    
print(" ".join(map(str,s)))