Harryxun/stf_run huggingface dataset:
N,M = list(map(int,input().split()))

e_list = [[] for i in range(N)]

for i in range(M):
    x,y = list(map(int,input().split()))
    x,y = x-1,y-1
    e_list[x].append(y)

memo = [-1]*N

def DFS(v):
    if memo[v]!=-1:
        return memo[v]
    if len(e_list[v])==0:
        memo[v] = 0
        return 0
    res = 0
    for v1 in e_list[v]:
        res1 = DFS(v1)
        if res<res1+1:
            res = res1+1
    memo[v] = res
    return res

ans = 0
for i in range(N):
    res = DFS(i)
    
    if res>ans:
        ans = res
print(ans)

### FIXED CODE ###

import sys

sys.setrecursionlimit(500000)


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

e_list = [[] for i in range(N)]

for i in range(M):
    x,y = list(map(int,input().split()))
    x,y = x-1,y-1
    e_list[x].append(y)

memo = [-1]*N

def DFS(v):
    if memo[v]!=-1:
        return memo[v]
    if len(e_list[v])==0:
        memo[v] = 0
        return 0
    res = 0
    for v1 in e_list[v]:
        res1 = DFS(v1)
        if res<res1+1:
            res = res1+1
    memo[v] = res
    return res

ans = 0
for i in range(N):
    res = DFS(i)
    if res>ans:
        ans = res
print(ans)
xyh = []
n = int(input())
for i in range(n):
	x, y, h = map(int, input().split())
	if h != 0:
		xyh.append([x, y, h])

judge = 0
for i in range(101):
	cx = i
	for j in range(101):
		cy = j
		h = []
		for k in range(n):
			h.append(xyh[k][2] + abs(xyh[k][0]-cx) + abs(xyh[k][1]-cy))
		if len(h) == 1:
			lst = [cx, cy, h[k]]
			lst = [str(i) for i in lst]
			print(" ".join(lst))
			exit(0)
		for k in range(len(h)-1):
			if h[k] != h[k+1]:
				break
			if k == len(h)-2:
				lst = [cx, cy, h[k]]
				lst = [str(i) for i in lst]
				print(" ".join(lst))
				exit(0)


### FIXED CODE ###

xyh = []
n = int(input())
for i in range(n):
	x, y, h = map(int, input().split())
	xyh.append([x, y, h])

for cx in range(101):
	for cy in range(101):
		h = 0
		judge = 1
		for k in range(n):
			if xyh[k][2] > 0:
				h = xyh[k][2] + abs(cx-xyh[k][0]) + abs(cy-xyh[k][1])
				break
		for k in range(n):
			if max(h - abs(cx-xyh[k][0]) - abs(cy-xyh[k][1]), 0) != xyh[k][2]:
				judge = 0
				break
		if judge:
			print(cx, cy, h)
			exit(0)
a = int(input())
s = input()

if a >= 2300:
  print(s)
  else:
    print(a)

### FIXED CODE ###

a = int(input())
s = input()

if a >= 3200:
  print(s)
else:
  print("red")
n = int(input())
x =list(map(int,input().split()))
def step(i,cost):
    if i>=3:
        return abs(x[-1]-cost)
    return min(step(i+1,x[i])+abs(cost-x[i]),step(i+2,x[i])+abs(cost-x[i]))
cost = x[0]
print(step(0,cost))

### FIXED CODE ###

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

dp = [0, abs(h[1]-h[0])]
if n >2:
    for i in range(2,n):
        dp.append(min(abs(h[i]-h[i-2])+dp[-2], abs(h[i]-h[i-1])+dp[-1]))
else:
    print(dp[-1])
    exit()

print(dp[-1])
n = input()
s = list(input())
a = {}
for i in range(1,int(n)+1):
    a[i] = int(s[2*i-2])

result = 0
for i in range(1,int(n)+1):
    if a[a[i]] == i:
        result = result+1
result = int(result/2)
print(result)

### FIXED CODE ###

s = input()
print(s[:4]+' '+s[4:])
N = int(input())

def shiki(x,y,z):
    return x**2 + y**2 + z**2 + x*y + y*z + z*x

anli = [0] * 10100


for x in range(1,150):
    if shiki(x,1,1) > N:
        break

    for y in range(1, x+1):
        if shiki(x,y,1) > N:
            break

        for z in range(1, y+1):
            if x == y and y == z:
                anli[shiki(x,y,z)] += 1
            elif x==y or y==z or z==x:
                anli[shiki(x,y,z)] += 3
            else:
                anli[shiki(x,y,z)] += 6
            if shiki(x,y,z) > N:
                break

for i in range(1,N+1):
    print(anli[i])


### FIXED CODE ###

N = int(input())

def shiki(x,y,z):
    return x**2 + y**2 + z**2 + x*y + y*z + z*x

anli = [0] * 10100


for x in range(1,150):
    if shiki(x,1,1) > N:
        break

    for y in range(1, x+1):
        if shiki(x,y,1) > N:
            break

        for z in range(1, y+1):
            
            if shiki(x,y,z) > N:
                break
            if x == y and y == z:
                anli[shiki(x,y,z)] += 1
            elif x==y or y==z or z==x:
                anli[shiki(x,y,z)] += 3
            else:
                anli[shiki(x,y,z)] += 6

for i in range(1,N+1):
    print(anli[i])
import numpy as P
M=10**9+7
n,k=map(int,input().split())
a=P.matrix([list(map(int,input().split()))for i in[0]*n],dtype='O')
b=P.eye(n,dtype='O')
while k:
 if k&1:b=b*a%M
 a=a*a%M
 k>>=1
print(b.sum()%M)

### FIXED CODE ###

import numpy
M=10**9+7
n,k=map(int,input().split())
a=numpy.matrix([list(map(int,input().split()))for i in[0]*n],dtype='O')
b=numpy.eye(n,dtype='O')
while k:
 if k&1:b=b*a%M
 a=a*a%M
 k>>=1
print(b.sum()%M)
n, m = map(int, input().split())
ans = ['t'] * n

for _ in range(m):
    s, c = map(int, input().split())
    if ans[s-1] =='t' or ans[s-1] == str(c):
        ans[s-1]= str(c)
    else:
        print(-1)
        exit(0)
if ans[0] == 't':
    ans[0]=str(1)

ans = ''.join(ans).replace('t', str(0))
ans = int(ans)
l = str(ans)
if len(l) != n:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

n = int(input())

print(int(n//2+n%2))
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
from statistics import mean, median,variance,stdev


def main():
	N, K = map(int, input().split(" "))
	A = input().split(" ")
	A = [int(s) for s in A]
	
	DP = [100000000000000000000000000000000 for _ in range(N)]
	DP[0] = 0
	
	for i, val in enumerate(A):
		if i == 0:
			continue
		tmp = 100000000000000000000000000000000
		
		for j in range(K):
			index = j+1
			if i >= index:
				tmp1 = DP[i-index] + abs(A[i-index] - val)
				tmp = min(tmp, tmp1)
			else:
				break
		DP[i] = min(DP[i], tmp)
		
	#print(DP)
	print(DP[N-1])
	
	
if __name__ == "__main__":
	main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys

def main():
	N, K = map(int, input().split(" "))
	H = input().split(" ")
	H = [int(s) for s in H]
	
	DP = [-1 for _ in range(N)]
	DP[0] = 0
	
	for i in range(1, len(H)):
		paths = [DP[j] + abs(H[j] - H[i]) for j in range(max(0, i-K), i)]
		DP[i] = min(paths)
		
	print(DP[N-1])
		
if __name__ == "__main__":
	main()
S = input()

if S[3]==S[4] and S[5] == S[6]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

S = input()

if S[2]==S[3] and S[4] == S[5]:
  print("Yes")
else:
  print("No")
cnt = int(input())
a = []
for i in range(cnt):
    li = list(map(int,input().split()))
    if li[0] == 0:
        if li[1] == 0:
            a.insert(0,li[2])
        else:
            a.insert(-1,li[2])
    if li[0] == 1:
        print(a[li[1]])
    if li[0] ==2:
        if li[1]==0:
            a.popleft()
        else:
            a.pop()


### FIXED CODE ###

from collections import deque
cnt = int(input())
a = deque()

for i in range(cnt):
    li = list(map(int,input().split()))
    if li[0] == 0:
        if li[1] == 0:
            a.appendleft(li[2])
        else:
            a.append(li[2])
    if li[0] == 1:
        print(a[li[1]])
    if li[0] ==2:
        if li[1]==0:
            a.popleft()
        else:
            a.pop()
n = int(input())
a = list(map(int, input().split()))

maxA = max(a)
count = 0

for e in a:
    for i in range(e,maxA+1,e):
        dp[i] += 1
        
for e in a:
    if dp[e] == 1:
        count += 1

print(count)


### FIXED CODE ###

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


maxA = max(a)
dp = [0]*(maxA+1)
count = 0

for e in a:
    for i in range(e,maxA+1,e):
        dp[i] += 1

for e in a:
    if dp[e] == 1:
        count += 1

print(count)
n = int(input())
l = []
l2 = []

for i in range(n):
    x, y = list(map(int, input().split()))
    l.append([x,y])

for i in range(len(l)):
    for j in range(i+1, len(l)):
        dif1 = l[i][0] - l[j][0]
        dif2 = l[i][1] - l[j][1]
        l2.append(str(dif1) + ' ' + str(dif2))


cnt = l2.count(max(l2, key=l2.count))

print(n - cnt)



### FIXED CODE ###

n = int(input())
l = []
l2 = []

for i in range(n):
    a, b = list(map(int, input().split()))
    l.append([a,b])
l.sort()

for i in range(len(l)-1):
    for j in range(i+1, len(l)):
        dif1 = l[i][0] - l[j][0]
        dif2 = l[i][1] - l[j][1]
        l2.append(str(dif1) + ' ' + str(dif2))
##print(l2)

try:
    cnt = max(l2, key=l2.count)
except:
    cnt = "1000000 1000000"
x, y = list(map(int, cnt.split()))

ans = 0

for i in range(len(l)):
    if [l[i][0] + x, l[i][1] + y] in l:
        ans += 1

print(n - ans)
n = int(input())
t = [int(input()) for _ in [0]*n]

def gcd(x, y):
	while y:
		x, y = y, x % y
	return x

def lcm(x, y):
  return x * y // gcd (x, y)

ans = lcm(t[0],t[1])
if n>=3:
  for i in range(2,n):
    ans = lcm(ans,t[i])
    
print(ans)    

### FIXED CODE ###

n = int(input())
t = [int(input()) for _ in [0]*n]

if n==1:
  print(t[0])
  exit()
  
def gcd(x, y):
	while y:
		x, y = y, x % y
	return x

def lcm(x, y):
  return x * y // gcd (x, y)

ans = lcm(t[0],t[1])
if n>=3:
  for i in range(2,n):
    ans = lcm(ans,t[i])
    
print(ans)
from collections import Counter

n, m = list(map(int, input().split()))
MOD = pow(10, 9) + 7

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def make_fact_list(n, MOD):
    # make factorial list from 0 to n
    fact = [0] * (n+1)
    inv = [0] * (n+1)
    factinv = [0] * (n+1)

    fact[0]=fact[1]=1
    inv[1]=1
    factinv[0]=factinv[1]=1

    for i in range(2,n+1):
        fact[i] = fact[i-1] * i % MOD
        inv[i] = MOD - (( inv[MOD % i] *  (MOD // i)) % MOD )
        factinv[i] = factinv[i-1] * inv[i] % MOD
    
    return fact, factinv

def cbn(n, k, MOD, fact = [], factinv = []):
    if len(fact) == 0 and len(factinv) == 0:
        fact, factinv = make_fact_list(n, MOD)
    return fact[n] * factinv[n-k] * factinv[k] % MOD


d = Counter(prime_factorize(m)).most_common()

l = d[0][1] + n 

fact, factinv = make_fact_list(l, MOD)

a = 1

for k, v in d:
    a *= cbn(v + n - 1, v, MOD, fact = fact, factinv = factinv) % MOD

print(a % MOD)

### FIXED CODE ###

from collections import Counter

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

if m == 1:
    print(1)
else:

    MOD = pow(10, 9) + 7

    def prime_factorize(n):
        a = []
        while n % 2 == 0:
            a.append(2)
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                a.append(f)
                n //= f
            else:
                f += 2
        if n != 1:
            a.append(n)
        return a

    def make_fact_list(n, MOD):
        # make factorial list from 0 to n
        fact = [0] * (n+1)
        inv = [0] * (n+1)
        factinv = [0] * (n+1)

        fact[0]=fact[1]=1
        inv[1]=1
        factinv[0]=factinv[1]=1

        for i in range(2,n+1):
            fact[i] = fact[i-1] * i % MOD
            inv[i] = MOD - (( inv[MOD % i] *  (MOD // i)) % MOD )
            factinv[i] = factinv[i-1] * inv[i] % MOD
        
        return fact, factinv

    def cbn(n, k, MOD, fact = [], factinv = []):
        if len(fact) == 0 and len(factinv) == 0:
            fact, factinv = make_fact_list(n, MOD)
        return fact[n] * factinv[n-k] * factinv[k] % MOD


    d = Counter(prime_factorize(m)).most_common()

    l = d[0][1] + n 

    fact, factinv = make_fact_list(l, MOD)

    a = 1

    for k, v in d:
        a *= cbn(v + n - 1, v, MOD, fact = fact, factinv = factinv) % MOD

    print(a % MOD)
print(input()+input())

### FIXED CODE ###

s,t = (i for i in input().split())
print(t+s)
words = list(map(int,input().split()))
a = words[0][-1:]
b = words[1][0]
c = words[1][-1:]
d = words[2][0]
if a==b and c == d:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

words = input().split()
a = words[0][-1:]
b = words[1][0]
c = words[1][-1:]
d = words[2][0]
if a==b and c == d:
  print('YES')
else:
  print('NO')
N = int(input())
lista = [int(x) for x in input().split()]
q = 0
for i in lista:
  q *= i
  if q > 10**18:
    print(-1)
    return
 print(q)

### FIXED CODE ###

def main():

    N = int(input())
    lista = [int(x) for x in input().split()]
    q = 1
    if 0 in lista:
        return print(0)
    for i in lista:
        q *= i
        if q > 10**18:
            print(-1)
            return
    print(q)


main()
a=input()
b=input()
if (a+b)%3==0:
  print "Possible"
else:
  print "Impossible"

### FIXED CODE ###

a,b=map(int,raw_input().split())
if (a+b)%3==0 or a%3==0 or b%3==0:
  print "Possible"
else:
  print "Impossible"
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    size, jumps = map(int, input().split())
    array = list(map(int, input().split()))
    dp = [999999999] * size
    dp[0]= 0
    #dp[1] = abs(array[0]- array[1])
    for i in range(size):
		for j in range(i+1,1+i+jumps):
			if j < size:
				dp[j] = min(dp[j], dp[i]+abs(array[i] - array[j]))
	print(dp[size-1])

if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys


def input():
    return sys.stdin.readline().strip()


def main():
    size, jumps = map(int, input().split())
    array = list(map(int, input().split()))
    dp = [999999999] * size
    dp[0]= 0
    dp[1] = abs(array[0]- array[1])
    for i in range(2,size):
        dp[i] = min(abs(array[i] - array[j]) + dp[j] for j in range(max(0, i - jumps), i))
    print(dp[size-1])

if __name__ == "__main__":
    main()
S=input()
K=int(input())
l = []
for i in range(len(S)):
  for j in range(i,len(S)):
    sub_s = S[i:j]
    l.append(sub_s)
ans = sorted(list(set(l)))
ans.remove('')
print(ans[K-1])

### FIXED CODE ###

S=input()
K=int(input())
l = []
for alpha in [chr(i) for i in range(97, 97+26)]:
  indexs = [k for k, v in enumerate(list(S)) if v == alpha]
  for index in indexs:
    for j in range(index,min(index+6,len(S)+1)):
      sub_s = S[index:j]
      l.append(sub_s)
  l = sorted(list(set(l)))
  if '' in l:
    l.remove('')
  if len(l) >= K:
    break
print(l[K-1])
import numpy as np
 
N, D = list(map(int, input().split()))
full_list = []
for i in range(N):
  full_list.append(list(map(int, input().split())))
 
result = 0
 
for i in range(N):
  for j in range(N-i-1):
    length = 0
    for s in range(D):
      length += (full_list[i][s] - full_list[j][s]) ** 2
    result += 1 if np.sqrt(length).is_integer() == True else 0
 
print(result)

### FIXED CODE ###

N,A,B = map(int, input().split())
 
print(min(N*A, B))
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def solve():
    s = input()
    t = input()
    hoge = 10000
    let = len(t)
    les = len(s)
    ans = 10000
    for i in range(les-let+1):
        hoge = s[i:i+let]
        piyo = 0
        for j, k in zip(hoge,t):
            if j != k:
                piyo += 1
        if piyo < ans:
            ans = piyo
    print(ans)
    return 0

if __name__ == "__main__":
    solve()


### FIXED CODE ###

import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def solve():
    d, t, s = map(int, input().split())
    if d > t*s:
        print("No")
    else:
        print("Yes")
    return 0

if __name__ == "__main__":
    solve()
from itertools import product


candidates = []
non_as = ["KIH", "B", "R", ""]
for seps in product(["A", ""], repeat=4):
    candidates.add("".append(sep + non_a for sep, non_a in zip(seps, non_as)))

print("YES") if input() in candidates else print("NO")


### FIXED CODE ###

candidates = []
seps = ["KIH", "B", "R", ""]
for i in range(1 << 4):
    has_A = []
    for j in range(4):
        if i >> j & 1:
            has_A.append("A")
        else:
            has_A.append("")
    candidate = []
    for a, sep in zip(has_A, seps):
        candidate.append(a + sep)
    candidates.append("".join(candidate))

print("YES") if input() in candidates else print("NO")
s = input()
print(s[::2]

### FIXED CODE ###

s = input()
print(s[::2])
s = input()
print(s[0] + len(s[1:-1]) + s[-1])

### FIXED CODE ###

s = input()
print(s[0] + str(len(s[1:-1])) + s[-1])
N, M = map(int, input().split())
a = [(1, int(i) for i in input().split())]
for _ in range(M):
    b, c = map(int, input().split())
    a.append((b, c))
a = sorted(a, key=lambda x: x[1])
ans = 0
t = 0
while t < N:
    b, c = a.pop()
    p = min(b, N-t)
    ans += p * c
    t += p
print(ans)


### FIXED CODE ###

n, m = map(int, input().split())
a = [(1, int(i)) for i in input().split()]
for _ in range(m):
    b, c = map(int, input().split())
    a.append((b, c))
a = sorted(a, key=lambda x: x[1])
ans = 0
t = 0
while t < n:
    b, c = a.pop()
    p = min(b, n-t)
    ans += p * c
    t += p
print(ans)
def solve(N,X,M):
    memo = [-1]*M
    acc = [0]*(M+1)
    x = X%M
    for i in range(M):
        if memo[x] >= 0:
            break
        acc[i+1] = acc[i]+x
        memo[x] = i
        x = (x*x)%M


    end = i
    start = memo[x]
    cycle = end - start

    if N < end:
        return acc[N]+(X - X%M)

    cycle_sum = acc[end]-acc[start]

    res = acc[start]+(X - X%M)

    N -= start
    res += (N//cycle)*cycle_sum
    res += acc[start+(N%cycle)]-acc[start]
    return res

N,X,M = map(int,input().split())
print(solve(N,X,M))


### FIXED CODE ###



def solve(N,X,M):
    if X == 0:
        return 0
    memo = [-1]*(M+3)
    acc = [0]*(M+4)
    x = X
    for i in range(M):
        if memo[x] >= 0:
            break
        acc[i+1] = acc[i]+x
        memo[x] = i
        x = (x*x)%M


    end = i
    start = memo[x]
    cycle = end - start

    if N < end:
        return acc[N]

    cycle_sum = acc[end]-acc[start]

    res = acc[start]

    N -= start
    res += (N//cycle)*cycle_sum
    res += acc[start+(N%cycle)]-acc[start]
    return res


N,X,M = map(int,input().split())
print(solve(N,X,M))
# D - Handstand

# 逆立ちしている人が連続する区間のインデックスを保存する
# 指示1回あたり2つの区間を繋ぐことができる
# 連続したK+1個の区間を順に選んで繋ぎ、最も逆立ち区間が長くなる場合を探す。端から繋ぐ場合は例外処理

N, K = map(int, input().split())
S = input()

if len(set(S)) == 1:
    print(N)
    exit()

handstand_range_idx = []
range_start_idx = 0
for idx in range(1,N):
    if (S[idx-1] == "1" and S[idx] == "0"):
        range_end_idx = idx - 1
        handstand_range_idx.append([range_start_idx, range_end_idx])
    elif idx == N-1 and S[idx] == "1":
        range_end_idx = idx
        handstand_range_idx.append([range_start_idx, range_end_idx])
    elif S[idx-1] == "0" and S[idx] == "1":
        range_start_idx = idx

ans = max(handstand_range_idx[K-1][1]+1, (N-1) - handstand_range_idx[-K][0] + 1)
for first_link_range_idx in range(len(handstand_range_idx)):
    try:
        ans = max(ans, handstand_range_idx[first_link_range_idx + K][1] - handstand_range_idx[first_link_range_idx][0] + 1)
    except IndexError:
        pass

print(ans)

### FIXED CODE ###

# D - Handstand

# 逆立ちしている人が連続する区間のインデックスを保存する
# 指示1回あたり2つの区間を繋ぐことができる
# 連続したK+1個の区間を順に選んで繋ぎ、最も逆立ち区間が長くなる場合を探す。端から繋ぐ場合は例外処理

N, K = map(int, input().split())
S = input()

if len(set(S)) == 1:
    print(N)
    exit()

handstand_range_idx = []
range_start_idx = 0
for idx in range(1,N):
    if (S[idx-1] == "1" and S[idx] == "0"):
        range_end_idx = idx - 1
        handstand_range_idx.append([range_start_idx, range_end_idx])
    elif idx == N-1 and S[idx] == "1":
        range_end_idx = idx
        handstand_range_idx.append([range_start_idx, range_end_idx])
    elif S[idx-1] == "0" and S[idx] == "1":
        range_start_idx = idx

ans = 0
try:
    ans = max(handstand_range_idx[K-1][1]+1, (N-1) - handstand_range_idx[-K][0] + 1)
except IndexError: # 逆立ち区間の数が操作回数よりも少ない場合
    print(N)
    exit()

for first_link_range_idx in range(len(handstand_range_idx)):
    try:
        ans = max(ans, handstand_range_idx[first_link_range_idx + K][1] - handstand_range_idx[first_link_range_idx][0] + 1)
    except IndexError:
        pass

print(ans)
import itertools

N, M = map(int, input().split())
G = [[]  for _ in range(N)]
for i in range(M):
    a, b = map(lambda x: int(x) - 1, input().split())
    G[a].append(b)
    G[b].append(a)
pattern = [i for i in range(N)]

ans = 0
for i in itertools.permutations(pattern):
    flag = True
    now = i[j]
    next = i[j+1]
    if i[0] != 0:
        continue
    for j in range(len(i) - 1):
        if not next in G[now]:
            flag = False
    if flag:
        ans += 1
print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
G = [[] for _ in range(N)]
seen = [False] * N
for i in range(M):
    a, b = map(lambda x: int(x) - 1 ,input().split())
    G[a].append(b)
    G[b].append(a)

def dfs(x, G, seen):
    seen[x] = True
    flag = True
    for i in seen:
        if i == False:
            flag = False
    if flag:
        return 1
    res = 0
    for i in G[x]:
        if seen[i]:
            continue
        res += dfs(i, G, seen)
        seen[i] = False
    return res

print(dfs(0, G, seen))
s=[]
s=list(srt(input().split()))
if s[2]==s[3] and s[4]==s[5]:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

s=[]
s=list((input()))
if s[2]==s[3] and s[4]==s[5]:
    print('Yes')
else:
    print('No')
X = int(input())
Y = int(input())
Z = int(input())
A = X
B = Y
C = Z
temp = A
A = B
B = temp
temp = A
A = C
C = temp

print(A, B, C);

### FIXED CODE ###

X, Y, Z = input().split()
A = X
B = Y
C = Z
temp = A
A = B
B = temp
temp = A
A = C
C = temp

print(A, B, C);
N = int(input())

if N < 111:
  print(111)
elif N < 222:
  print(222)
elif N < 333:
  print(333)
elif N < 444:
  print(444)
elif N < 555:
  print(555)
elif N < 666:
  print(666)
elif N < 777:
  print(777)
elif N < 888:
  print(888)
elif N =< 999:
  print(999)

### FIXED CODE ###

# 入力
N=int(input())

while True:
  # 1種類の文字しか使われない場合が答え
  if len(set(str(N)))==1:
    print(N)
    break

  # 次の数へ
  N+=1
n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
if m>1:
    for i in range(m-1):
        if a[i+1]-a[i]==1:
            print(0)
            exit()
def fb(num):
    a,b = 1,0
    for _ in range(num+1):
        a,b = a+b,a
    return b
c=0
for i in range(m):
    if i==0 and a[0]==1:
        c+=1
    elif i==0:
        c+=fb(a[0]-1)
    else:
        c*=(fb(a[i]-a[i-1]-2)%(10**9+7))
    print(c)
c*=fb(n-a[-1]-1)%(10**9+7)
print(c%(10**9+7))

### FIXED CODE ###

n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
def fb(num):
    a,b = 1,0
    for _ in range(num+1):
        a,b = a+b,a
    return b
if m==0:
    print(fb(n)%(10**9+7))
    exit()
if m>1:
    for i in range(m-1):
        if a[i+1]-a[i]==1:
            print(0)
            exit()
c=0
for i in range(m):
    if i==0 and a[0]==1:
        c+=1
    elif i==0:
        c+=fb(a[0]-1)
    else:
        c*=(fb(a[i]-a[i-1]-2)%(10**9+7))
c*=fb(n-a[-1]-1)%(10**9+7)
print(c%(10**9+7))
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)
n = int(input())
A = list(map(int, input().split()))
def left(i):
    if i < 1:
        return 0
    return gcd(left(i-1), A[i-1])
def right(i):
    if i+1 > n-1:
        return 0
    # ここA[i+1]じゃなくてA[i]
    return gcd(right(i+1), A[i]) 
ans = 0
for i in range(n):
    ans = max(ans, gcd(left(i), right(i)))
print(ans)

### FIXED CODE ###

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)
n = int(input())
A = list(map(int, input().split()))
L = [0]*n
R = [0]*n
for i in range(n-1):
    R [i+1] = gcd(R[i], A[i])
    L[i+1] = gcd(L[i], A[-i-1])
print(max(gcd(R[i], L[-i-1]) for i in range(n)))