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

from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque

n,k = [int(x) for x in stdin.readline().rstrip().split()]
a = [0] + [int(x) for x in stdin.readline().rstrip().split()]

m = 0
b = [1]

c = 1
for i in range(n):
    c = a[c]
    if c not in b:
        b.append(c)
        if i == k-1:
            print(c)
            sys.exit()
    else:
        break

idx = b.index(c)
bn = len(b[idx:])
sn = len(b[:idx])

# print(b,idx,sn,bn)
kk = (k-sn) % bn
print(b[idx+kk])

### FIXED CODE ###

from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque

n,k = [int(x) for x in stdin.readline().rstrip().split()]
a = [0] + [int(x) for x in stdin.readline().rstrip().split()]

m = 0
b = [1]
visited = [-1 for i in range(n+1)]

c = 1
visited[1] = 1
for i in range(n):
    c = a[c]
    if visited[c] != 1:
        b.append(c)
        visited[c] = 1
        if i == k-1:
            print(c)
            sys.exit()
    else:
        break

idx = b.index(c)
bn = len(b[idx:])
sn = len(b[:idx])

# print(b,idx,sn,bn)
kk = (k-sn) % bn
print(b[idx+kk])
### BUGGY CODE ###

import sys
N=int(sys.stdin.readline())
L=list(map(int,sys.stdin.readline().split()))
count=[0]*N
C=list(set(L))
x=0
d=[0]*len(C)
e=[0]*N
for i in range(len(C)):
  d[i] = int((L.count(C[i]))*(L.count(C[i])-1)/2)
  x += d[i]  
for K in range(N):
  e[K] = L.count(L[K])-1
  print(x-e[K])


### FIXED CODE ###

import sys
from collections import Counter
N=int(sys.stdin.readline())
L=list(map(int,sys.stdin.readline().split()))
C=Counter(L)
x=0
for a in C.values():
  x += int(a*(a-1)/2)  
for K in range(N):
  print(x-C[L[K]]+1)
### BUGGY CODE ###

from scipy.misc import comb

n = int(input())
a = list(map(int,input().split()))
for i in range(n):
    l = a[i]
    a[i] = 'X'
    ans = 0
    a_s = set(a)
    for j in a_s:
        c = a.count(j)
        if c < 2:
            continue
        ans += comb(c,2,exact=True)
    print(ans)
    a[i] = l

### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int,input().split()))

c = Counter(a)
key = c.keys()
comb = 0
for i in key:
    comb += (c[i]) * (c[i]-1) // 2

for i in a:
    ans = comb - (c[i]-1)
    print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

import numpy as np

N = int(input())
S = []

a_ascii = ord('a')
bins_of_char = np.zeros((N, 26),dtype=np.int)
num_of_anagram = 0

for i in range(N):
    S.append(input())

for i in range(N):
    for char in S[i]:
        char_num = ord(char) - a_ascii
        bins_of_char[i, char_num] += 1

for i in range(0, N-1):
    for j in range(i+1, N):
        if np.all(bins_of_char[i] == bins_of_char[j]):
            num_of_anagram += 1

print(num_of_anagram)

### FIXED CODE ###

# -*- coding: utf-8 -*-

# refered to editorial

import numpy as np

N = int(input())
S = []
hash_table = {}

a_ascii = ord('a')
bins_of_char = np.zeros((N, 26),dtype=np.int)
num_of_anagram = 0

for i in range(N):
    S.append(''.join(sorted(input())))
S = sorted(S)

for i in range(N):
    if S[i] in hash_table:
        num_of_anagram += hash_table[S[i]]
        hash_table[S[i]] += 1
    else:
        hash_table[S[i]] = 1


print(num_of_anagram)
### BUGGY CODE ###

n, k = map(int, input().split())
s = input()

s = '1' + s + '1'

cnt_1 = []
cnt_0 = []
stack_1 = 0
stack_0 = 0
for i in s:
    if i == '1':
        if stack_0 > 0:
            cnt_0.append(stack_0)
            stack_0 = 0
        stack_1 += 1
    else:
        if stack_1 > 0:
            cnt_1.append(stack_1)
            stack_1 = 0
        stack_0 += 1
if stack_1 > 0:
    cnt_1.append(stack_1)

if len(cnt_1) == 0 or len(cnt_0) == 0:
    print(n)
    exit()
cnt_1[0] -= 1
cnt_1[-1] -= 1
cum_1 = []
cum_0 = []
if k > len(cnt_0):
    k = len(cnt_0)
for i in range(len(cnt_1)-k):
    cum_1.append(sum(cnt_1[i:i+k+1]))
for i in range(len(cnt_0)-k+1):
    cum_0.append(sum(cnt_0[i:i+k]))

res = []
for v, w in zip(cum_1, cum_0):
    res.append(v+w)
print(max(res))

### FIXED CODE ###

n, k = map(int, input().split())
s = input()

s = '1' + s + '1'

cnt_1 = []
cnt_0 = []
stack_1 = 0
stack_0 = 0
for i in s:
    if i == '1':
        if stack_0 > 0:
            cnt_0.append(stack_0)
            stack_0 = 0
        stack_1 += 1
    else:
        if stack_1 > 0:
            cnt_1.append(stack_1)
            stack_1 = 0
        stack_0 += 1
if stack_1 > 0:
    cnt_1.append(stack_1)

if len(cnt_1) == 0 or len(cnt_0) == 0:
    print(n)
    exit()
cnt_1[0] -= 1
cnt_1[-1] -= 1

if k > len(cnt_0):
    k = len(cnt_0)
cum_1 = [sum(cnt_1[:k+1])]
cum_0 = [sum(cnt_0[:k])]
for i in range(1, len(cnt_1)-k):
    cum = cum_1[i-1] + cnt_1[i+k] - cnt_1[i-1]
    cum_1.append(cum)
for i in range(1, len(cnt_0)-k+1):
    cum = cum_0[i-1] + cnt_0[i+k-1] - cnt_0[i-1]
    cum_0.append(cum)
res = []

for v, w in zip(cum_1, cum_0):
    res.append(v+w)
print(max(res))
### BUGGY CODE ###

N, Q = (int(i) for i in input().split())
S = input()

L = []
R = []
for i in range(Q):
    L, R = (int(i) for i in input().split())
    old_len = len(S)
    print(S[(L-1):R].count('AC'))

### FIXED CODE ###

N, Q = (int(i) for i in input().split())
S = input()

counts = 0
totals = [0]
for i in range(1, N):
  if S[i-1] == 'A' and S[i] == 'C':
    counts += 1
  totals.append(counts)

L = []
R = []
for i in range(Q):
    L, R = (int(i) for i in input().split())
    print(totals[R-1] - totals[L-1])
### BUGGY CODE ###

# -*- coding: utf-8 -*-

from collections import deque

n = int(input())
edges = [list(map(int, input().split())) for i in range(n-1)]

# 使われていない色を保持する
nodes = [deque([i for i in range(1, n)]) for j in range(n)]

tree = {}
for edge in sorted(edges):
    a = edge[0] # 頂点a
    b = edge[1] # 頂点b

    color = nodes[a-1].popleft()
    tree[(a, b)] = color
    nodes[b-1].remove(color)

print(max(tree.values()))
for edge in edges:
    a = edge[0] # 頂点a
    b = edge[1] # 頂点b
    print(tree[(a, b)])

### FIXED CODE ###

# -*- coding: utf-8 -*-

from collections import deque

n = int(input())
edges = [list(map(int, input().split())) for i in range(n-1)]

tree = {}
node_in = [0 for i in range(n)] # 頂点に入る辺は1つ
node_out = [[0] for i in range(n)] # 頂点から出る辺は1つ以上
for edge in sorted(edges):
    a = edge[0] # 頂点a
    b = edge[1] # 頂点b

    color = 0
    if node_out[a-1][-1] == 0:
        if node_in[a-1] <= 1: # node_in[a-1] == 0の時1、1の時2なのでまとめて
            color = node_in[a-1] + 1
        else: # node_in[a-1] >= 2
            color = 1
    else:
        color = node_out[a-1][-1] + 1
        if node_in[a-1] == color:
            color += 1
            
    tree[(a, b)] = color
    node_out[a-1].append(color)
    node_in[b-1] = color

print(max(tree.values()))
for edge in edges:
    a = edge[0] # 頂点a
    b = edge[1] # 頂点b
    print(tree[(a, b)])
### BUGGY CODE ###

from collections import defaultdict

def get_p(ind):
    global parent
    while parent[ind] != ind:
        ind = parent[ind]
    return ind

def get_p2(ind):
    global parent
    if parent[ind] != ind:
        parent[ind] = get_p2(parent[ind])
    return parent[ind]

parent = []

def main():
    global parent

    num, swap = map(int, input().split())
    data = list(map(int, input().split()))

    parent = [i for i in range(num + 1)]

    for i in range(swap):
        a, b = map(int, input().split())
        a_parent = get_p2(a)
        b_parent = get_p2(b)

        if a_parent != b_parent:
            parent[max(a_parent, b_parent)] = min(a_parent, b_parent)


    ans = 0


    for i in range(num):
        now_int = i + 1
        ind = data.index(i + 1)
        ind += 1
        if get_p(now_int) == get_p(ind):
            ans += 1
        elif ind == now_int:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###



def get_p(ind):
    if parent[ind] != ind:
        parent[ind] = get_p(parent[ind])
    return parent[ind]



num, swap = map(int, input().split())
data = list(map(int, input().split()))

parent = [i for i in range(num + 1)]

for i in range(swap):
    a, b = map(int, input().split())
    a_parent = get_p(a)
    b_parent = get_p(b)
    if a_parent != b_parent:
        parent[max(a_parent, b_parent)] = min(a_parent, b_parent)

ans = 0

for i in range(num):
    now_int = i + 1
    ind =  data[i]
    if get_p(now_int) == get_p(ind):
        ans += 1
    elif ind == now_int:
        ans += 1

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

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


def inpl():
    return list(map(int, input().split()))


def countp(cp, p):
    ret = 0
    while cp % p == 0:
        ret += 1
        cp //= p
    return ret


def count_in(fx_dict):
    if not fx_dict:
        return 2
    ret = 1
    for v in fx_dict:
        ret *= (v + 1)
    return ret


def main():
    N = int(input())
    va = [i for i in range(N + 1)]
    fx = [[] for _ in range(N + 1)]
    for p in range(2, N + 1):
        if va[p] == 1:
            continue
        for cp in range(p, N + 1, p):
            tmp = countp(cp, p)
            va[cp] //= p**tmp
            fx[cp].append(tmp)
    # print(fx)

    ans = 1
    for i in range(2, N + 1):
        if va[i] != 1:
            fx[i].append(1)
        tmp = count_in(fx[i])
        # print(i, tmp)
        ans += i * tmp

    print(ans)
    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

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


def inpl():
    return list(map(int, input().split()))


def main():
    N = int(input())
    ans = 0
    for i in range(1, N + 1):
        n = N // i
        ans += n * (n + 1) * i // 2
    print(ans)
    return


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

n = int(input())
l = list(map(int, input().split()))
l.sort(reverse = True)

ans = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if l[i] < l[j] + l[k]:
                ans += 1

print(ans)

### FIXED CODE ###

import bisect

n = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(n):
    for j in range(i+1, n):
        x = bisect.bisect_left(l, l[i] + l[j])
        ans += x - j - 1
print(ans)
### BUGGY CODE ###

import itertools
L = [0]
N = int(input())
A = list(map(int, input().split()))
cnt = 0
dic = {}
dic[0] = 1
for i in range(N):
    n = L[-1] + A[i]
    L.append(n)
    dic.setdefault(n, 0)
    dic[n] += 1
for key in dic.keys():
    if dic[key] > 1:
        cnt += len(list(itertools.combinations(range(dic[key]), 2)))
print(int(cnt))

### FIXED CODE ###

from math import factorial as f
L = [0]
N = int(input())
A = list(map(int, input().split()))
cnt = 0
dic = {}
dic[0] = 1
for i in range(N):
    n = L[-1] + A[i]
    L.append(n)
    dic.setdefault(n, 0)
    dic[n] += 1
for key in dic.keys():
    if dic[key] > 1:
        cnt += f(dic[key]) // f(2) // f(dic[key] - 2)
print(int(cnt))
### BUGGY CODE ###

n, k  = list(map(int, input().split()))
h = list(map(int, input().split()))
c = [0]*n

for i in range(1, n):
  hi = h[i]
  c[i] = min(abs(hi-h[i-j-1]) + c[i-j-1] for j in range(min(i, k)))
  
print(c[-1])


### FIXED CODE ###

n, k  = list(map(int, input().split()))
h = list(map(int, input().split()))

c = [0]
for i in range(1, n):
  tmp = 10**100
  for j in range(1, min(i, k)+1):
    tmp = min(abs(h[i] - h[i - j]) + c[i - j], tmp)
  c.append(tmp)
  
print(c[-1])
### BUGGY CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M = map(int, input().split())

uf = UnionFind(N)

for i in range(M):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)

all_group_members = uf.all_group_members()
ans = 0
for i in range(N):
    ans = max(ans, uf.size(i))

print(ans)




### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M = map(int, input().split())

uf = UnionFind(N)
# check = set()

for i in range(M):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)
    # check.add(a-1)

# ans = 0
# for i in check:
#     ans = max(ans, uf.size(i))

print(min(uf.parents)*(-1))

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

N, K = map(int, input().split())
A = list(map(int, input().split()))

A_dict = {}
rewrite = 0

for a in A:
    if a in A_dict:
        A_dict[a] += 1
    else:
        A_dict[a] = 1

while len(A_dict) > K:
    rewrite_key = min(A_dict, key=A_dict.get)
    rewrite += A_dict[rewrite_key]
    del A_dict[rewrite_key]

print(rewrite)


### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))

A_dict = {}
for a in A:
    if a in A_dict:
        A_dict[a] += 1
    else:
        A_dict[a] = 1

A_sorted = sorted(A_dict.items(), key=lambda x:x[1], reverse=True)
rewrite = 0
while len(A_sorted) > K:
    tmp = A_sorted.pop()
    rewrite += tmp[1]

print(rewrite)
### BUGGY CODE ###

if __name__ == '__main__':
    input_list = list(map(int, input().split()))
    N = input_list[0]
    M = input_list[1]

    A = [0]*N
    B = [0]*N

    for i in range(N):
        A[i], B[i] = map(int, input().split())

    for i in range(N):
        if i == 0:
            prices = [A[0]]*B[0]
        else:
            prices.extend([A[i]]*B[i])

    sorted_prices = sorted(prices)

    answer = 0

    for i in range(M):
        answer += sorted_prices[i]

    print(answer)

### FIXED CODE ###

if __name__ == '__main__':
    input_list = list(map(int, input().split()))
    N = input_list[0]
    M = input_list[1]

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

    sorted_AB = sorted(AB, key=lambda x:x[0])

    answer = 0
    cnt = 0
    for e in sorted_AB:
        pre_cnt = cnt

        Ai = e[0]
        Bi = e[1]

        cnt = min(M, cnt+Bi)
        answer += Ai * (cnt - pre_cnt)

        if cnt == M:
            break

    print(answer)
### BUGGY CODE ###

A,B,K = map(int,input().split())
i = 0
while i < K:
    if A != 0:
        A -= 1
    else:
        B -= 1
    i += 1
print(str(A) + " " + str(B))

### FIXED CODE ###

def main():
    a,b,k = map(int,input().split())
    if a >= k:
        a-=k
    else:
        b -= (k - a)
        a = 0
        if b < 0:
            b = 0
    print(str(a)+" "+str(b))
main()
### BUGGY CODE ###

import math
k = int(input())
ans = []
for x in range(1,k+1):
    for y in range(1,k+1):
        for z in range(1,k+1):
           xy = math.gcd(x,y)
           ans.append(math.gcd(xy,z))
print(sum(ans))


### FIXED CODE ###

import math
k = int(input())
ans = []
for x in range(1,k+1):
    for y in range(1,k+1):
        for z in range(1,k+1):
           xy = math.gcd(x,y)
           ans.append(math.gcd(xy,z))
print(sum(ans))
### BUGGY CODE ###

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
k = max(a)
for i in range(n):
    if a[i] != k:
        print(k)
    else:
        tmp = a[i]
        a[i] = 0
        print(max(a))
        a[i] = tmp

### FIXED CODE ###

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
bl = [0 for i in range(n)]
bl[0] = a[0]
br = [0 for i in range(n)]
br[0] = a[n - 1]
for i in range(1, n):
    bl[i] = max(bl[i - 1],a[i])
a.reverse()
for i in range(1, n):
    br[i] = max(br[i - 1],a[i])
br.reverse()
print(br[1])
for i in range(1, n - 1):
    print(max(bl[i - 1],br[i + 1]))
print(bl[n - 2])
### BUGGY CODE ###

#!/usr/bin/env python3

n = str(input())

ans = 0
count = 1
for i in reversed(n):
    ans += count*int(i)
    ans = ans % 9
    count *= 10
if ans == 0:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

#!/usr/bin/env python3

n = str(input())

ans = 0
count = 1
for i in reversed(n):
    ans += int(i)
    ans = ans % 9
    count *= 10
if ans == 0:
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

n = int(input())
l = []
for i in range(n):
    l.append(int(input()))
           
for j in range(n):
    print(max(l[:j]+l[j+1:]))  

### FIXED CODE ###

n = int(input())
l = []
for i in range(n):
	l.append(int(input()))
           
s = sorted(l, reverse=True)
      
for value in l:
    if value == s[0]:
        print(s[1])
    else:
        print(s[0])
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
aa = []
for s in a:
    aa.append(s)
for s in a:
    aa.append(s)
g = sum(a)//2
ans = []
for i in range(n):
    temp = sum([aa[i+1+j*2] for j in range(n//2)])
    ans.append(g-temp)
for k in ans:
    print(2*k,end=" ")
        

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
aa = a+a
g = sum(a)//2
ans = []
for i in range(1):
    temp = sum([aa[i+1+j*2] for j in range(n//2)])
    ans.append(g-temp)
temp = ans[0]
for i in range(1,n):
    temp = a[i-1] - temp
    ans.append(temp)
for k in ans:
    print(2*k,end=" ")
### BUGGY CODE ###

it = input()
it = it.split()
n = int(it[0])
m = int(it[1])
p1 = []
p2 = []
for _ in range(m):
    itf = input()
    itf = itf.split()
    a = int(itf[0])
    b = int(itf[1])
    p1.append(a)
    p2.append(b)
d = [1, ]
c = [0, ]
l = 0
flag = True
for j in range(1, n):
    for i, t in enumerate(p1):
        if t == d[l]:
            d.append(p2[i])
            c.append(t)
    for i, t in enumerate(p2):
        if t == d[l]:
            d.append(p1[i])
            c.append(t)
    if len(d) > l:
        l += 1
    else:
        flag = False
        break
con = []
for i in range(2, n+1):
    for y, j in enumerate(d):
        flfl = True
        if j == i:
            con.append(c[y])
            flfl=False
            break
        if not flfl:
            break
    if flfl:
        con.append(0)
        break

if 0 in con:
    print('No')
else:
    print('Yes')
    for i in con:
        print(i)


### FIXED CODE ###

it = input()
it = it.split()
n = int(it[0])
m = int(it[1])
p = [[] for _ in range(n)]
for _ in range(m):
    itf = input()
    itf = itf.split()
    a = int(itf[0])
    b = int(itf[1])
    p[a-1].append(b)
    p[b-1].append(a)
d = [1, ]
con = [0] * n
while d:
    l = d.pop(0)
    for k in p[l-1]:
        if con[k-2]==0:
            d.append(k)
            con[k-2] = l
print('Yes')
for i in range(n-1):
    print(con[i])
### BUGGY CODE ###

import sys
n, k = map(int, input().split())
a = [int(i) for i in input().split()]
towns = [1]
prev = 1
count = 0
while len(towns) == len(set(towns)):
    next = a[prev - 1]
    towns.append(next)
    prev = next
    count += 1
    if count == k:
        print(next)
        sys.exit()
i = towns.index(next)
repeat = towns[i: -1]
unit = len(repeat)
rest = k - count + 1
print(repeat[(rest % unit) - 1])

### FIXED CODE ###

import sys
from collections import defaultdict
n, k = map(int, input().split())
a = [int(i) for i in input().split()]
towns = [1]
town_dic = defaultdict(lambda : 0)
prev = 1
count = 0
while True:
    next = a[prev - 1]
    count += 1
    if count == k:
        print(next)
        sys.exit()
    if town_dic[next] == 1:
        break
    else:
        town_dic[next] += 1
    towns.append(next)
    prev = next
i = towns.index(next)
repeat = towns[i:]
unit = len(repeat)
rest = k - count + 1
print(repeat[(rest % unit) - 1])
### BUGGY CODE ###

n,m = list(map(int,input().split()))

a = []
b = []
for i in range(m):
    aa,bb = list(map(int,input().split()))
    a.append(aa)
    b.append(bb)
c = []
for i in range(m):
    if a[i] == 1:
        c.append(b[i])

ans = 'IMPOSSIBLE'
for i in range(m):
    if a[i] in c and b[i] == n:
        ans = 'POSSIBLE'
    elif b[i] in c and a[i] == n:
        ans = 'POSSIBLE'
print(ans)

### FIXED CODE ###

n,m = list(map(int,input().split()))

a = []
b = []
for i in range(m):
    aa,bb = list(map(int,input().split()))
    a.append(aa)
    b.append(bb)
c = []
d = []
for i in range(m):
    if a[i] == 1:
        c.append(b[i])
    elif a[i] == n:
        d.append(b[i])
    elif b[i] == n:
        d.append(a[i])

ans = 'IMPOSSIBLE'
c = set(c)
d = set(d)

if len(c&d) >= 1:
    ans = 'POSSIBLE'
print(ans)
### BUGGY CODE ###

X = int(input())
A = 0
while True:
    diff = X - A**5
    if diff < 0:
        minus_flg = False
        diff = abs(diff)
    else:
        minus_flg = True
    B = pow(diff, 0.2)
    if (isinstance(B, float)) and B.is_integer():
        break
        A += 1
if minus_flg:
    B = int(B)*-1
print(A, int(B))

### FIXED CODE ###

X = int(input())

for a in range(-118, 121):
    for b in range(-118, 121):
        if (a**5 - b**5) == X:
            break
    else:
        continue
    break
print(a, b)
### BUGGY CODE ###

N = int(input())
A = []

a = int(input())

val = [a]
length = 1

for _ in range(N - 1) :
    a = int(input())
    i = 0

    while i < length :
        if val[i] < a :
            val[i] = a
            break
        i += 1
    else :
        val.append(a)
        length += 1

print(length)

### FIXED CODE ###

import bisect

N = int(input())
A = []

a = int(input())

val = [-a]
length = 1

for _ in range(N - 1) :
    a = int(input())
    a *= -1
    i = 0

    index = bisect.bisect_right(val, a)
    if index >= length :
        val.append(a)
        length += 1
    else :
        val[index] = a

print(length)
### BUGGY CODE ###

l,r=map(int,input().split())
g = list([i%2019 for i in range(l,r+1)])
m=[]
for i in range(len(g)-1):
    for j in range(i+1,len(g)):
        m.append(g[i]*g[j]%2019)
print(min(m))

### FIXED CODE ###

l,r=map(int,input().split())
if r - l >= 2019:
    print(0)
    exit()
g = list([i%2019 for i in range(l,r+1)])
m=[]
for i in range(len(g)-1):
    for j in range(i+1,len(g)):
        m.append(g[i]*g[j]%2019)
print(min(m))