Harryxun/stf_run huggingface dataset:
n, k = map(int, input().split())
A = list(map(int, input().split()))
if n == 1:
    print('IMPOSSIBLE')
    exit()
A.sort()
D = [A[i + 1] - A[i] for i in range(n - 1)]
from math import *
g = D[0]
for d in D:
    g = gcd(g, d)
print('POSSIBLE'if g == 1 else 'IMPOSSIBLE')


### FIXED CODE ###

def possible(b):
    print('POSSIBLE' if b else 'IMPOSSIBLE')
    exit()

n, k = map(int, input().split())
A = list(set(map(int, input().split())))
n = len(A)

if k in A:
    possible(True)

if k > max(A):
    possible(False)

if n == 1:
    possible(False)

A.sort()
D = [A[i + 1] - A[i] for i in range(n - 1)]
from fractions import *
g = D[0]
for d in D:
    g = gcd(g, d)

possible(k % g == 0)
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
import fractions
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

n = I()
A = LI()

cnt = [0] * n

for i in range(n-1):
    if cnt[A[i]-1] == 0:
        cnt[A[i]-1] = A.count(A[i])

for c in cnt:
  print(c)


### FIXED CODE ###

from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
import fractions
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

n = I()
A = LI()

cnt = [0] * n

sa = set(A)
csa = Counter(A)

for v in sa:
    if cnt[v-1] != 0:
        continue
    cnt[v-1] = csa[v]

for c in cnt:
  print(c)
i = input().split()
a = int(i[0])
b = int(i[0]+i[2:])
print(a * b // 100)

### FIXED CODE ###

i = input().split()
a = int(i[0])
b = int(i[1][0]+i[1][2:])
print(a * b // 100)
a, b, x = map(int, input().split())
import math

S = a*b
s = x/a

if s >= S/2:
  em_s = S-s
  tan = (a**2)/(2*em_s)
  ans = math.degrees(math.atan(tan))
  print(90-ans)
else:
  tan = (2*s)/(b**2)
  ans = math.degrees(math.atan(tan))
  print(90-ans)

### FIXED CODE ###

a, b, x = map(int, input().split())
import math

S = a*b
s = x/a
if s == S:
  print(0)

elif s >= S/2:
  em_s = S-s
  tan = (a**2)/(2*em_s)
  ans = math.degrees(math.atan(tan))
  print(90-ans)

else:
  tan = (2*s)/(b**2)
  ans = math.degrees(math.atan(tan))
  print(90-ans)
from itertools import combinations
import numpy as np
N, M, X = map(int,input().split())
xx = np.array([X]*M)
C = {}
cs = []
for _ in range(N):
    c, *A = map(int,input().split())
    C[c] = A
    cs.append(c)
ans = float('inf')
for i in range(0, N+1):
    for comb in combinations(cs,i):
        tmp = 0
        x = xx.copy()
        for cos in comb:
            tmp += cos
            x -= np.array(C[cos])
        if len(x[x <= 0]) >= M:ans = min(ans,tmp)
if ans == float('inf'):ans = '-1'
print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
idx = 1
S = [idx]
ed = set([idx])

for i in range(1, K+1):
    idx = A[idx-1]
    if idx in ed:
        start = S.index(idx)
        end = len(S)
        n = start + (K - start) % (end - start)
        print(S[n])
        break
    else:
        S.append(idx)
        ed.add(idx)
        continue
else:
    print(idx)
n = int(input())
a = list(map(int,input().split()))
count = 1
if 0 in a:
  print(0)
  exit()
for num in a:
    count *= num
	if count > 10**18:
    	print(-1)
        exit()
print(count)


### FIXED CODE ###

n = int(input())
lis = list(map(int,input().split()))
ans = 1
if 0 in lis:
  print(0)
  exit()
for num in lis:
  ans *= num
  if ans > 10 ** 18:
    print(-1)
    exit()
print(ans)
n = int(input())
a = map(int, input().split())

for i in range(n):
    no = a[i]
    if (no%2==0) and (no%3!=0) and (no%5!=0):
        print('DENIED')
        exit()
print('APPROVED')

### FIXED CODE ###

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

for i in range(n):
    no = a[i]
    if (no%2==0) and (no%3!=0) and (no%5!=0):
        print('DENIED')
        exit()
print('APPROVED')
N=int(input())
if N // 2 = 0:
  print(N)
else:
  print(N*2)

### FIXED CODE ###

N=int(input())
if N % 2 == 0:
  print(N)
else:
  print(N*2)
N = int(input())
V = list(map(int,input().rstrip().split(' ')))
V.sort(reverse=True)

sum = 0
for i, v in enumerate(V):
    sum += v/(2**(i+1)))
sum += V[-1]/(2**(N-1))
print(sum)

### FIXED CODE ###

N = int(input())
V = list(map(int,input().rstrip().split(' ')))
V.sort(reverse=True)

sum = 0
for i, v in enumerate(V):
    sum += v/(2**(i+1))
sum += V[-1]/(2**(N))
print(sum)
from collections import defaultdict
import numpy as np
N = int(input())
A = list(map(int, input().split()))

D = defaultdict(int)

ans = 0

for i, a in enumerate(A):
    ans += D[i-a]
    D[i+a] += 1

print(ans)


### FIXED CODE ###

from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))

D = defaultdict(int)

ans = 0

for i, a in enumerate(A):
    ans += D[i-a]
    D[i+a] += 1

print(ans)
N, T = list(map(int, input().split()))
ans=10000

for i in range(N):
  c, tt==list(map(int, input().split()))
  if tt <= T:
    ans=min(c,ans)

if ans==10000:
  print('TLE')
else:
  print(ans)

### FIXED CODE ###

N, T = list(map(int, input().split()))
ans=10000

for i in range(N):
  c, tt=list(map(int, input().split()))
  if tt <= T:
    ans=min(c,ans)

if ans==10000:
  print('TLE')
else:
  print(ans)
N, K = map(int, input().split())
H = sorted([int(input()) for _ in range(N)])
ret = 10 ** 9
for i in range(N-K+1):
    ret = min(H[i+2] - H[i], ret)

print(ret)

### FIXED CODE ###

N, K = map(int, input().split())
H = sorted([int(input()) for _ in range(N)])
ret = 10 ** 9
for i in range(N-K+1):
    ret = min(H[i+K-1] - H[i], ret)
print(ret)
a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print('red)

### FIXED CODE ###

a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print('red')
n = input()
s, t = input().split()
ans = ''
for i in range(n):
  ans += s[i] + t[i]
print(ans)

### FIXED CODE ###

n = int(input())
s, t = input().split()
ans = ''
for i in range(n):
  ans += s[i] + t[i]
print(ans)
max = 0
i = 0
j = 0
k = 0
n_max = 0

n_max = int(raw_input())
price = [1,2,3,4,5]

for i in range(5):
  for j in range(5):
    if max <= price[5] - price[i]:
      print max

### FIXED CODE ###

import sys

n = int(raw_input())

min_R = int(raw_input())
nums = map(int, sys.stdin.readlines())

ans = -10**9

for num in nums:
    if num - min_R > ans:
        ans = num - min_R
    if num < min_R:
        min_R = num
        
print ans
import itertools


def resolve():
    n, m = map(int, input().split())
    S = [[0] * m for i in range(n)]

    for i in range(m):
        a, b = map(int, input().split())
        S[a - 1][b - 1] = 1
        S[b - 1][a - 1] = 1

    ans = 0
    for p in itertools.permutations(range(n)):
        if p[0] != 0:
            break
        tmp = 1
        for i in range(n-1):
            tmp *= S[p[i]][p[i + 1]]
        if tmp == 0:
            break
        ans += tmp

    print(ans)

if __name__ == '__main__':
    resolve()

### FIXED CODE ###

# サンプルコード計算量お試し

import itertools

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

for i in range(M):
    a, b = map(int, input().split())
    adj_matrix[a-1][b-1] = 1
    adj_matrix[b-1][a-1] = 1

cnt = 0

for each in itertools.permutations(range(N)):
    if each[0] != 0:
        break
    factor = 1
    for i in range(N-1):
        factor *= adj_matrix[each[i]][each[i+1]]
    cnt += factor

print(cnt)
N = map(str,input().split())

NC = int(N.count("o"))

print(700+NC*100)

### FIXED CODE ###

N = list(input().strip(","))

NC = int(N.count("o"))

print(700+NC*100)
inf = float("inf")

minPaths = {}

stone, jump = map(int, input().split())
weights = tuple(map(int, input().split()))

for i in range (stone):
  minPaths[i+1] = inf

#find shortest paths
minPaths[1] = 0

for node in range(1, stone + 1):
  cWeight = minPaths[node]
  
  #calculate to next K nodes
  try:
    for go in range (1, jump + 1):
    	toNext = abs(weights[node-1] - weights[node+go-1])
        
    	if minPaths[node + go] > cWeight + toNext:
          minPaths[node + go] = cWeight + toNext
  except KeyError:
    None
print (minPaths[stone])


### FIXED CODE ###

inf = float("inf")

minPaths = {}
weights = {}

stone = int(input())
wei = tuple(map(int, input().split()))

for i in range (stone):
  minPaths[i+1] = inf
  weights[i+1] = wei[i]

#find shortest paths
minPaths[1] = 0

for node in range(1, stone + 1):
  cWeight = minPaths[node]
  
  #calculate to nwxt 2 nodes
  try:
    toP1 = abs(weights[node] - weights[node+1])
    if toP1 + cWeight < minPaths[node+1]:
      minPaths[node+1] = toP1 + cWeight

    toP2 = abs(weights[node] - weights[node+2])
    if toP2 + cWeight < minPaths[node+2]:
      minPaths[node+2] = toP2 + cWeight
  except KeyError:
    None
print (minPaths[stone])
count = 1

for:
    x = input()
    if x == 0: break
    else:
        {i}.format(i=count)
        print("Case{i}:" x)
        count = count + 1

### FIXED CODE ###

c = 1
x = input()
while x != "0":
    print("Case {}: {}".format(c, x))
    x = input()
    c += 1
a,b,c,d,e,k=map(int,input())
if b-a<=k and c-b<=k and d-c<=k and e-d<=k:
    print('Yay!')
else:
    print(':(')

### FIXED CODE ###

a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if b-a<=k and c-a<=k and d-a<=k and e-a<=k and c-b<=k and d-b<=k and e-b<=k and d-c<=k and e-c<=k and e-d<=k:
    print('Yay!')
else:
    print(':(')
N=int(input())
c_0=0
c_1=0
c_2=0
c_3=0
for i in range(N):
  s_i=input()
  if s_i=="AC":
    c_0=c_0+1
  elif s_i=="WA":
    c_1=c_1+1
  elif s_i=="TLE":
    c_2=c_2+1
  elif s_i=="RE":
    c_3=c_3+1
print("AC x "+c_0)
print("WA x "+c_1)
print("TLE x "+c_2)
print("RE x "+c_3)

### FIXED CODE ###

N=int(input())
c_0=0
c_1=0
c_2=0
c_3=0
for i in range(N):
  s_i=input()
  if s_i=="AC":
    c_0=c_0+1
  elif s_i=="WA":
    c_1=c_1+1
  elif s_i=="TLE":
    c_2=c_2+1
  elif s_i=="RE":
    c_3=c_3+1
print("AC x "+str(c_0))
print("WA x "+str(c_1))
print("TLE x "+str(c_2))
print("RE x "+str(c_3))
a, b = map(int, input().split())
count = 0
for i in range(a, b):
    s = str(i)
   if(len(s) == 1):
      break
    for j in range(len(s) // 2):
        if(s[j] != s[len(s)-1-j]):
            break
    else:
        count += 1
print(count)    

### FIXED CODE ###

a, b = map(int, input().split())
count = 0
for i in range(a, b+1):
    s = str(i)
    if(len(s) == 1):
        count += 1
        break
    for j in range(len(s) // 2):
        if(s[j] != s[len(s)-1-j]):
            break
    else:
        count += 1
print(count)
import sys

lines = sys.stdin.readlines()

a, b, k = map(int, lines[0].split())

if a => k:
  a = 0
  k = k - a
  if b => k:
    b = 0
    k = k - b
else:
  a = a - k
  
print(a, b)

### FIXED CODE ###

import sys

lines = sys.stdin.readlines()

a, b, k = map(int, lines[0].split())

if a <= k:
    k = k - a
    a = 0
    if b <= k:
        k = k - b
        b = 0
    else:
        b = b - k
else:
    a = a - k

print(a, b)
H,W = map(int,input().split())
s = [list(input()) for _ in range(W)]
dp = [[0] * W for _ in range(H)]

if s[0][0] == '#':
  dp[0][0] = 1
else:
  dp[0][0] = 0

for i in range(1,W):
  if s[0][i] == '.':
    dp[0][i] = dp[0][i-1]
  else:
    dp[0][i] = dp[0][i-1]+1
for i in range(1,H):
  for j in range(W):
    if j == 0:
      if s[i][j] == '.':
        dp[i][j] = dp[i-1][j]
      else:
        dp[i][j] = dp[i-1][j]+1
    else:
      if s[i][j] == '.':
        dp[i][j] = min(dp[i-1][j],dp[i][j-1])
      else:
        dp[i][j] = min(dp[i-1][j]+1,dp[i][j-1]+1)
print(dp[-1][-1])

### FIXED CODE ###

H,W = map(int,input().split())
s = [list(input()) for _ in range(H)]
dp = [[0] * W for _ in range(H)]
dp[0][0] = int(s[0][0]=="#")

for i in range(1, W):
    dp[0][i] = dp[0][i-1] + (int(s[0][i]=="#") if s[0][i-1]=="." else 0)
for h in range(1,H):
  dp[h][0] = dp[h-1][0] + (int(s[h][0]=="#") if s[h-1][0]=="." else 0)
  for w in range(1,W):
    dp[h][w] = min(dp[h-1][w]+(int(s[h][w]=="#") if s[h-1][w]=="." else 0), 
    dp[h][w-1]+(int(s[h][w]=="#") if s[h][w-1]=="." else 0))
print(dp[-1][-1])
import itertools

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

for i in range(N):
    x, y = map(int, input().split(' '))
    balls.append([x,y])

ans = 100
for pat in list(itertools.permutations(balls)):
    dic = {}
    l = list(pat)
    px = l[0][0]
    py = l[0][1]
    t_max = 0
    for i in range(1,len(l)):
        dx = l[i][0] - px
        dy = l[i][1] - py
        px = l[i][0]
        py = l[i][1]
        if (dx,dy) not in dic.keys():
            dic[(dx,dy)] = 1
        else:
            dic[(dx,dy)] += 1
            if (t_max < dic[(dx,dy)]):
                t_max = dic[(dx,dy)]
        kitai = + N - i
        if ans < (N - kitai):
            break
    d_max = max(dic.values())
    cost = N - d_max
    if (cost < ans):
        ans = cost

print(ans)


### FIXED CODE ###

N = int(input())
balls = []
for i in range(N):
    x, y = map(int, input().split(' '))
    balls.append((x,y))

if N == 1:
    print("1")
    exit()

dic = {}
for i in range(N):
    for j in range(i+1,N):
        dx = balls[j][0] - balls[i][0]
        dy = balls[j][1] - balls[i][1]
        if (dx,dy) not in dic.keys():
            dic[(dx,dy)] = 1
        else:
            dic[(dx,dy)] += 1
        dx *= -1
        dy *= -1
        if (dx,dy) not in dic.keys():
            dic[(dx,dy)] = 1
        else:
            dic[(dx,dy)] += 1

d_max = max(dic.values())
print(N - d_max)
# -*- coding: utf-8 -*-

import random
def qui(l):
    num = len(l)
    if num <= 1:
        return l
    piv = random.randrange(0,len(l))
    piv2 = random.randrange(0,len(l))
    piv3 = random.randrange(0,len(l))
    if (l[piv] > l[piv2]) and (l[piv2] > l[piv3]):
        piv = piv2
    elif (l[piv] > l[piv3]) and (l[piv3] > l[piv2]):
        piv = piv3
    elif (l[piv] < l[piv2]) and (l[piv2] < l[piv3]):
        piv = piv2
    elif (l[piv] < l[piv3]) and (l[piv3] < l[piv2]):
        piv = piv3
    else:
        pass
    mini = []
    maxi = []

    for i in range(0,len(l)):
        if i == piv:
            continue
        if l[piv] > l[i]:
            mini.append(l[i])
        elif l[piv] <= l[i]:
            maxi.append(l[i])
    mini = qui(mini)
    maxi = qui(maxi)
    return mini+[l[piv]]+maxi
input()
list1 = input().split(" ")
for i in range(0, len(list1)):
    list1[i] = int(list1[i])

result = qui(list1)

print(' '.join(map(str, result)))

### FIXED CODE ###

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

import random
def qui(l):
    num = len(l)
    if num <= 1:
        return l
    piv = random.randrange(0,len(l))
    piv2 = random.randrange(0,len(l))
    piv3 = random.randrange(0,len(l))
    if (l[piv] > l[piv2]) and (l[piv2] > l[piv3]):
        piv = piv2
    elif (l[piv] > l[piv3]) and (l[piv3] > l[piv2]):
        piv = piv3
    elif (l[piv] < l[piv2]) and (l[piv2] < l[piv3]):
        piv = piv2
    elif (l[piv] < l[piv3]) and (l[piv3] < l[piv2]):
        piv = piv3
    else:
        pass
    mini = []
    middlei = []
    maxi = []

    for i in range(0,len(l)):
        if l[i] == l[piv]:
            middlei.append(l[i])
        elif l[piv] > l[i]:
            mini.append(l[i])
        elif l[piv] <= l[i]:
            maxi.append(l[i])
    mini = qui(mini)
    maxi = qui(maxi)
    return mini+ middlei+maxi
input()
list1 = input().split(" ")
for i in range(0, len(list1)):
    list1[i] = int(list1[i])

result = qui(list1)

print(' '.join(map(str, result)))
s = int(input())
memo = [-1]
memo.append(s)
def a(n):
    if memo[n-1] % 2 == 0:
        pre = memo[n-1]/2
        for i in memo:
            if i == pre:
                return n
            else:
                memo.append(pre)
                return a(n+1)
    else:
        pre = 3 * memo[n-1] + 1
        for i in memo:
            if i == pre:
                return n
            else:
                memo.append(pre)
                return a(n+1)

print(a(2))

### FIXED CODE ###

s = int(input())
memo = [-1]
memo.append(s)
def a(n):
    if memo[n-1] % 2 == 0:
        pre = memo[n-1]/2
        for i in memo:
            if i == pre:
                return n
        memo.append(pre)
        return a(n+1)
    else:
        pre = 3 * memo[n-1] + 1
        for i in memo:
            if i == pre:
                return n
        memo.append(pre)
        return a(n+1)

print(a(2))
n = int(input())
k = int(input())
ref = 1

for i in range(n):
  if ref * 2 < ref + k:
    ref *= 2
  else:
    ref += k

print(ref)

### FIXED CODE ###

import math
n = int(input())
print(int(math.sqrt(n))**2)
s = ['Sunny', 'Cloudy', 'Rainy']
print(s[s.index(input()) + 1 % 3])

### FIXED CODE ###

s = ['Sunny', 'Cloudy', 'Rainy']
print(s[(s.index(input())+1) % 3])
s=input()
t=input()
n=len(s)
m=len(t)
dp=[[0 for i in range(n+1)] for j in range(m+1)]
for i in range(n):
  for j in range(m):
    if s[i]==t[j]:
      dp[i+1][j+1]=dp[i][j]+1
    else:
      dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])
l=dp[n][m]
ans=''
a=n
b=m
while a>0 and b>0:
  if dp[a][b]==dp[a-1][b]:
    a-=1
  elif dp[a][b]==dp[a][b-1]:
    b-=1
  else:
    a-=1
    b-=1
    ans=s[a]+ans
print(ans)

     

### FIXED CODE ###

s=input()
t=input()
n=len(s)
m=len(t)
dp=[[0 for i in range(m+1)] for j in range(n+1)]
for i in range(n):
  for j in range(m):
    if s[i]==t[j]:
      dp[i+1][j+1]=dp[i][j]+1
    else:
      dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])
ans=''
a=n
b=m
while a>0 and b>0:
  if dp[a][b]==dp[a-1][b]:
    a-=1
  elif dp[a][b]==dp[a][b-1]:
    b-=1
  else:
    a-=1
    b-=1
    ans=s[a]+ans
print(ans)
# coding: utf-8
import math

num_N = int(input())

min_num = math.inf
sqrt_N = math.floor(math.sqrt(num_N))

for i in range(1, sqrt_N + 1):
    if num_N % i == 0:
        len_num_A = len(str(i))
        len_num_B = len(str(num_N // i))
        min_num = min(min_num, max(len_num_A, len_num_B))

print(min_num)

### FIXED CODE ###

# coding: utf-8
import math

num_N = int(input())

min_num = 999999
sqrt_N = math.floor(math.sqrt(num_N))

for i in range(1, sqrt_N + 1):
    if num_N % i == 0:
        len_num_A = len(str(i))
        len_num_B = len(str(int(num_N / i)))
        min_num = min(min_num, max(len_num_A, len_num_B))

print(min_num)
n=int(input())
a=list(map(int,input().split()))
l=[0 for i in range(100001)]
ans=0
for i in range(n):
    l[a[i]]+=1
for i in range(100001):
    if 0<l[i]<i:
        ans+=l[i]
    if i<l[i]:
        t=l[i]-i
        ans+=t
print(ans)        

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
l=[0 for i in range(10**5+1)]
ans=0
for i in range(n):
    if a[i]>10**5:
        ans+=1
    else:
        l[a[i]]+=1
for i in range(10**5+1):
    if 0<l[i]<i:
        ans+=l[i]
    if i<l[i]:
        t=l[i]-i
        ans+=t
print(ans)
#!/usr/bin/env python3

from pprint import pprint
from collections import deque, defaultdict
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline
INF = float("inf")

x = int(input())


def find(x):
    for a in range(300):
        for b in range(300):
            b = -b
            if a ** 5 - b ** 5 == x:
                return [a, b]


a, b = find(x)
print(a, b)


### FIXED CODE ###

#!/usr/bin/env python3

import sys

input = sys.stdin.buffer.readline

x = int(input())


def find(x):
    for a in range(-300, 300):
        for b in range(-300, 300):
            b = -b
            if a ** 5 - b ** 5 == x:
                return [a, b]


a, b = find(x)
print(a, b)
# 動的計画法のテーブルを用意
# dp(n) は頂点nを始点として時の最大有効パスの長さ

def get_inputs():
    N, M = map(int, input().split())
    
    # グラフgを初期化
    g = [[] for _ in range(N)]
    
    # 辺情報を読み込みgに追加
    for _ in range(M):
        x, y = map(lambda c: int(c) - 1, input().split())
        g[x].append(y)
    
    return N, M, g


def getlp(x):
    global dp, g
    
    if dp[x] != -1:
        return dp[x]
    elif len(g[x]) == 0:
        dp[x] = 0
        return dp[x]
    else:
        mxp = 0
        for y in g[x]:
            yp = getlp(y)
            if yp > mxp:
                mxp = yp
        dp[x] = mxp + 1
        return dp[x]


N, M, g = get_inputs()

dp = [-1] * N
ans = 0
for x in range(N):
    ans = max(ans, getlp(x))

print(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)

def get_inputs():
    N, M = map(int, input().split())
    
    # グラフgを初期化
    g = [[] for _ in range(N)]
    
    # 辺情報を読み込みgに追加
    for _ in range(M):
        x, y = map(lambda c: int(c) - 1, input().split())
        g[x].append(y)
    
    return N, M, g


def getlp(x):
    global dp, g
    
    if dp[x] != -1:
        return dp[x]
    elif len(g[x]) == 0:
        dp[x] = 0
        return dp[x]
    else:
        dp[x] = max([getlp(y) for y in g[x]]) + 1
        return dp[x]


N, M, g = get_inputs()

dp = [-1] * N
ans = 0
for x in range(N):
    ans = max(ans, getlp(x))

print(ans)
a = input()
M,N = map(int,a.spliit())

if M == N:
  print(Yes)

else:
  print(No)


### FIXED CODE ###

i = input()
a,b = map(int, i.split())

if a>b:
 print("No")
elif a<b:
 print("No")
else:
 print("Yes")
import heapq

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

ans = []
for i in range(min(N, K)+1):
  for j in range(i+1):
    #print(i-j, j)
    # i-j個左から、i個右から取る
    lst = V[:i-j] + V[2*N-j:]
    #print(lst)
    heapq.heapify(lst)
    for _ in range(K-i):
      if len(lst) == 0:
        break
      elif min(lst) >= 0:
        ans.append(sum(lst))
        break
      else:
        heapq.heappop(lst)
        ans.append(sum(lst))
        #print(ans)
print(max(ans))

### FIXED CODE ###

import heapq

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

ans = [V[0]]
for i in range(min(N, K)+1):
  for j in range(i+1):
    #print(i-j, j)
    # i-j個左から、i個右から取る
    lst = V[:i-j] + V[2*N-j:]
    #print(lst)
    heapq.heapify(lst)
    for _ in range(K-i):
      if len(lst) == 0:
        break
      elif min(lst) >= 0:
        ans.append(sum(lst))
        break
      else:
        heapq.heappop(lst)
        ans.append(sum(lst))
        #print(ans)
print(max(ans))
a = int(input())
b = int(input())

if (b*a) % 2 ==0:
    print("Even")
else:
    print("Odd")

### FIXED CODE ###

a,b = map(int,input().split())
if (a% 2 ==0)or(b% 2 ==0):
    print("Even")
else:
    print("Odd")
import numpy as np
    n = int(input())
    a = list(map(int, input().split()))
    l1 = np.zeros(61, dtype=np.int64)
    mod = 10**9+7
    for i in a:
        j = list(map(int, reversed(bin(i)[2:])))
        l1[:len(j)] += j
    l0 = n-l1
    ans = 0
    for i in range(len(l1)):
        ans = (ans+l0[i]*l1[i]*pow(2, i, mod)) % mod
    print(ans)


main()

### FIXED CODE ###

def main():
    n=int(input())
    a=list(map(int,input().split()))
    l1=[0]*61
    for i in a:
        j=list(reversed(bin(i)[2:]))
        for k in range(len(j)):
            if j[k]=="1":
                l1[k]+=1
    l0=[n-i for i in l1]
    ans=0
    mod=10**9+7
    for i in range(len(l1)):
        ans=(ans+l0[i]*l1[i]*pow(2,i,mod))%mod
    print(ans)
main()
import sys
readllne = sys.stdin.readllne()
A,B,C = map(int,readllne().split())
print(C,A,B)

### FIXED CODE ###

import sys
#readline = sys.stdin.readline()
A,B,C = map(int,input().split())
print(C,A,B)
strings = list(raw_input())
new_strings = ""
for string in strings:
  if string.islower():
    new_strings.append(string.upper()+',')
  else:
    new_strings.append(string.lower()+',')
print  new_strings

### FIXED CODE ###

print raw_input().swapcase()
a,b = map(int,input())
if a != 1:
  a -= 2
if b != 1:
  b -= 2
print(a * b)

### FIXED CODE ###

a,b = map(int,input().split())
if a != 1:
  a -= 2
if b != 1:
  b -= 2
print(a * b)
a = int(raw_input())
b = int(raw_input())
print a*b (a+b)*2

### FIXED CODE ###

a,b=map(int,raw_input().split())
print a*b,(a+b)*2