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

import sys
input = sys.stdin.readline

def main():
    H, W = map(int, input().split())
    P = W+1
    A = [list(map(int, input().split())) for _ in range(H)]
    B = [list(map(int, input().split())) for _ in range(H)]
    L = 80*80*2
    dp = [[False]*(L+1) for _ in range((W+1)*(H+1))]
    for h in range(H+1):
        dp[h*P][0] = True
    for w in range(H+1):
        dp[w][0] = True
    
    for h in range(H):
        for w in range(W):
            c = abs(A[h][w] - B[h][w])
            for l in range(L+1):
                b1 = abs(l-c)
                b2 = abs(l+c)
                if b1 <= L:
                    dp[(h+1)*P+w+1][l] = dp[h*P+w+1][b1] or dp[(h+1)*P+w][b1]
                if b2 <= L:
                    dp[(h+1)*P+w+1][l] = dp[(h+1)*P+w+1][l] or dp[h*P+w+1][b2] or dp[(h+1)*P+w][b2]

    for l in range(L+1):
        if dp[H*P+W][l]:
            print(l)
            break


if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    H, W = map(int, input().split())
    P = W+1
    A = [list(map(int, input().split())) for _ in range(H)]
    B = [list(map(int, input().split())) for _ in range(H)]
    L = 80*80
    dp = [[False]*(L+1) for _ in range((W+1)*(H+1))]
    dp[P+1][abs(A[0][0]-B[0][0])] = True
    
    for h in range(H):
        for w in range(W):
            if h == 0 and w == 0: continue
            c = abs(A[h][w] - B[h][w])
            for l in range(L-c+1):
                b1 = abs(l-c)
                b2 = abs(l+c)
                dp[(h+1)*P+w+1][l] = dp[h*P+w+1][b1] or dp[(h+1)*P+w][b1] or dp[h*P+w+1][b2] or dp[(h+1)*P+w][b2]

    for l in range(L+1):
        if dp[H*P+W][l]:
            print(l)
            break


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

def main():
    N=int(input())
    c=input()
    
    #x...WR
    #o...RR, RW, WW
    #Wが来たらそれ以降はW
    #R(0個以上)+W(0個以上)
    
    i=0
    for _ in range(N):
        if 'WR' in c:
            x=c.index('WR')  
            y=N-c[::-1].index('R')-1
            cl=list(c)
            cl[x]='R'
            cl[y]='W'
            c=''.join(cl)
            #c=c[:x]+'R'+c[x+1:y]+'W'+c[y+1:]
            #print(c)
            #print(x,y)
            i+=1
    #print(i) 
    print(min(c.count('R'),c.count('W'),i))
    
 
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    N=int(input())
    c=list(input())
    
    #x...WR
    #o...RR, RW, WW
    #Wが来たらそれ以降はW
    #R(0個以上)+W(0個以上)
    
    res=0
    cR=c.count('R')
    cW=c.count('W')
    
    l,r=0,N-1
    while l!=r:
        if c[l]=='W':
            if c[r]=='R':
                c[l],c[r]='R','W'
                res+=1
            else:
                r-=1
        else:
            l+=1
        
    print(min(cR,cW,res))
    
 
if __name__ == '__main__':
    main()
### BUGGY CODE ###

n,m = map(int, input().split())
a = list(map(lambda x: int(x)-1, input().split()))

score = [0]*(2*m)
for i in range(n-1):
    cur, nxt = a[i], a[i+1]
    if cur > nxt:
        nxt += m
    for j in range(nxt-cur):
        score[cur+j+1] -= j

for i in range(m):
    score[i] += score[i+m]

# argmin
x = tmp = 0
for i in range(m):
    if score[i] < tmp:
        x = i
        tmp = score[i]
        
ans = 0

def cnt(cur, nxt):
    if cur > nxt:
        nxt += m
    return nxt-cur

for i in range(n-1):
    cur, nxt = a[i], a[i+1]
    ans += min(cnt(cur, nxt), cnt(x, nxt)+1)

print(ans)

### FIXED CODE ###

class Binary_Indexed_Tree():
    def __init__(self, n):
        self.bit = [0]*n
        self.n = n
    def add(self, ind, num):
        while(ind <= self.n):
            self.bit[ind - 1] += num
            ind += ind & -ind
    def sum(self, ind):
        ret = 0
        while(ind > 0):
            ret += self.bit[ind-1]
            ind -= ind & -ind
        return ret

class Binary_Indexed_Tree_RAQ_RSQ():
    def __init__(self,n):
        self.p = Binary_Indexed_Tree(n+1)
        self.q = Binary_Indexed_Tree(n+1)

    def add(self, s,t,x):
        t += 1
        self.p.add(s,-x*s)
        self.p.add(t, x*t)
        self.q.add(s,x)
        self.q.add(t,-x)

    def sum(self, s, t):
        t += 1
        return self.p.sum(t) + self.q.sum(t)*t - self.p.sum(s) - self.q.sum(s)*s

n,m = map(int, input().split())
a = list(map(lambda x: int(x)-1, input().split()))
score = Binary_Indexed_Tree_RAQ_RSQ(2*m+10)


for i in range(n-1):
    cur, nxt = a[i], a[i+1]
    if cur > nxt:
        nxt += m
    if cur + 2 <= nxt:
        score.add(cur+3, nxt+1, 1)
        k = nxt-cur-1
        score.add(nxt+2, nxt+2, -k)

scores = [score.sum(0, i+1)+score.sum(0, i+m+1) for i in range(m)]

x = tmp = 0
for i in range(m):
    if scores[i] > tmp:
        x = i
        tmp = scores[i]
ans = 0

def cnt(cur, nxt):
    if cur > nxt:
        nxt += m
    return nxt-cur

for i in range(n-1):
    cur, nxt = a[i], a[i+1]
    ans += min(cnt(cur, nxt), cnt(x, nxt)+1)

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

import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
b = 1
mod = 10**9+7

for i in range(n):
        b *= a[i]

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

### FIXED CODE ###

import sys
input = sys.stdin.readline

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

for i in range(n):
    b *= a[i]
    if b > 10 ** 18:
        b = -1
        break

for i in range(n):
    if a[i] == 0:
        b = 0

print(b)
### BUGGY CODE ###

import math
x = int(input())
i = int(math.sqrt(x))
while (i < x):
    if (x%i == 0):
        print (int((x/i)+i)-2)
        break
    i += 1

### FIXED CODE ###

import math
x = int(input())
i = int(math.sqrt(x))
while (i < x):
    if (x%i == 0):
        print (int((x/i)+i)-2)
        break
    i -= 1
### BUGGY CODE ###

n = int(input())
m = int(n ** 0.5) + 1
for i in range(1,n+1):
  cnt = 0
  for x in range(1, m):
    for y in range(1, m):
      if (x+y)**2-4*(x**2+y**2+x*y-i) >0:
        z = (-(x+y)+((x+y)**2-4*(x**2+y**2+x*y-i))**0.5)/2       
        if z%1 == 0 and z>0:            
          cnt += 1
      else:
        break
  print(cnt)

### FIXED CODE ###

n = int(input())

a = [0]*10001

for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1,101):
        v = x*x+y*y+z*z+x*y+y*z+x*z
        if  v < 10001:
        	a[v] += 1
for i in range(n):
  print(a[i+1])
### BUGGY CODE ###

def h1(key):
    return key % m


def h2(key):
    return 1 + key % (m - 1)


def h(key, i):
    return h1(key + i * h2(key)) % m


def insert(T, key):
    i = 0
    while True:
        j = h(key, i)
        if T[j] is None:
            T[j] = key
            return j
        else:
            i += 1


def search(T, key):
    i = 0
    while True:
        j = h(key, i)
        if T[j] == key:
            return j
        elif T[j] is None or i >= m:
            return None
        else:
            i += 1


global m
r = {"A": 1, "C": 2, "G": 3, "T": 4, }
t = []
m = int(input())
for i in range(m):
    cmd, key = input().split()
    if cmd == "insert":
        t.append(key)
    else:
        if key in t:
            print("yes")
        else:
            print("no")

### FIXED CODE ###

t = set()
m = int(input())
for i in range(m):
    cmd, key = input().split()
    if cmd == "insert":
        t.add(key)
    else:
        if key in t:
            print("yes")
        else:
            print("no")
### BUGGY CODE ###

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

for i in range(N):
    k=i+1
    B = A[:]
    B.pop(i)
    C = [0]*(N+1)
    for l in range(N-1):
        C[B[l]] += 1
    temp = 0
    for m in range(N-1):
        temp += int(C[m]*(C[m]-1)/2)
    print(temp)

### FIXED CODE ###

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

B = [0]*(N+1)
for l in range(N):
    B[A[l]] += 1
ans = 0
for i in range(N+1):
    ans += int(B[i] * (B[i]-1) / 2)
for k in range(N):
        print(ans - B[A[k]] + 1)
### BUGGY CODE ###

N = int(input())
n = len(str(N)) - 1
ans = 0
for i in range(3, n+1):
  ans += 3**i - (2**i)*3 + 3

t = 3**n - 2**(n+1) + 1

if int(str(N)[0]) == 3:
  for i in range(3*(10**n), N+1):
    s = set([j for j in str(i)])
    if ('5' in s) and ('7' in s) and (len(s)==3):
      ans += 1
elif int(str(N)[0]) == 4:
  ans += t
elif int(str(N)[0]) == 5:
  ans += 3**n - (2**n)*3 + 3 + 2**n - 2
  for i in range(5*(10**n), N+1):
    s = set([j for j in str(i)])
    if ('3' in s) and ('7' in s) and (len(s)==3):
      ans += 1
elif int(str(N)[0]) == 6:
  ans += 2*t
elif int(str(N)[0]) == 7:
  ans += 2*t
  for i in range(7*(10**n), min(N+1, 8*(10**n))):
    s = set([j for j in str(i)])
    if ('3' in s) and ('5' in s) and (len(s)==3):
      ans += 1
elif int(str(N)[0]) > 7:
  ans += 3*t
print(ans)

### FIXED CODE ###

N = int(input())

def dfs(n):
  if int(n) > N:
    return 0
  if ('3' in n) and ('5' in n) and ('7' in n):
    ret = 1
  else:
    ret = 0
  for c in '357':
    ret += dfs(n+c)
  return ret

print(dfs('0'))
### BUGGY CODE ###

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

first = []
second = []
for i in range(m):
    a = list(map(int, input().split()))
    if a[0] == 1:
        first.append(a[1])
    if a[1] == n:
        second.append(a[0])


for i in first:
    if i in second:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

### FIXED CODE ###

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

first = []
second = []
for i in range(m):
    a = list(map(int, input().split()))
    if a[0] == 1:
        first.append(a[1])
    if a[1] == n:
        second.append(a[0])


if len(set(first) & set(second)) > 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
### BUGGY CODE ###

n = int(input())
aa = tuple(map(int, input().split()))

def dfs(money, stock, i):
    global aa
    global n

    if i == n:
        return money

    ns = money // aa[i]
    return max(
        dfs(money, stock, i + 1),
        dfs(money + stock * aa[i], 0, i + 1),
        dfs(money - aa[i] * ns, stock + ns, i + 1)
    )

ans = dfs(1000, 0, 0)
print(ans)

### FIXED CODE ###

from collections import defaultdict

n = int(input())
aa = tuple(map(int, input().split()))

x = {0: 1000}
for i in range(n):
    xx = defaultdict(int)
    for stock, money in x.items():
        xx[0] = max(xx[0], money + stock * aa[i])
        ns = money // aa[i]
        xx[stock + ns] = max(xx[stock + ns], money - ns * aa[i])
    x = xx
print(x[0])
### BUGGY CODE ###

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

#n,k = 5,3
#h = [10,30,40,50,20]

dp = [0] * n
dp[0] = 0

for i in range(1,n):
  x = []
  s = max(0,i-k)
  for j in range(s,i):
    x.append(dp[j] + abs(h[j] - h[i]))
  dp[i] = min(x)

print(dp[n-1])

### FIXED CODE ###

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

dp = [0] * n
dp[0] = 0

for i in range(1,n):
  s = max(0,i-k)
  x = [ dp[j] + abs(h[j] - h[i]) for j in range(s,i) ]
  dp[i] = min([ dp[j] + abs(h[j] - h[i]) for j in range(s,i) ])

print(dp[n-1])
### BUGGY CODE ###

n = int(input())
L = [None]+list(input().split())
even = []
odd = []
if n % 2 == 0:
    for i in range(1,1+n):
        if i % 2 == 0:
            even.append(L[i])
        else:
            odd.append(L[i])
    for j in range(len(even[::-1])):
        if j == len(even) - 1:
            print(even[::-1][j],end=' ')
        else:
            print(even[::-1][j],end=' ')
    for y in range(len(odd)):
        if y == len(odd) - 1:
            print(odd[y],end='')
        else:
            print(odd[y],end=' ')
    print()
else:
    for i in range(1,1+n):
        if i % 2 == 0:
            even.append(L[i])
        else:
            odd.append(L[i])
    for y in range(len(odd[::-1])):
        if y == len(odd) - 1:
            print(odd[::-1][y],end=' ')
        else:
            print(odd[::-1][y],end=' ')
    for x in range(len(even)):
        if x == len(even) -1:
            print(even[x],end='')
        else:
            print(even[x],end=' ')
    print()

### FIXED CODE ###

n = int(input())
L = [None]+list(input().split())
even = []
odd = []
if n % 2 == 0:
    for i in range(1,1+n):
        if i % 2 == 0:
            even.append(L[i])
        else:
            odd.append(L[i])
    for x in even[::-1]:
        print(x,end=' ')
    for y in odd:
        print(y,end=' ')
    print()
else:
    for i in range(1,1+n):
        if i % 2 == 0:
            even.append(L[i])
        else:
            odd.append(L[i])
    for y in odd[::-1]:
        print(y,end=' ')
    for x in even:
        print(x,end=' ')
    print()
### BUGGY CODE ###

from itertools import permutations
N, M, R = map(int, input().split())
r = map(int, input().split())
d = [[float('inf') for j in range(N)] for i in range(N)]
for i in range(N):
    d[i][i] = 0

for i in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    t = min(c, d[a][b])
    if d[a][b] > c:
        d[a][b], d[b][a] = t, t
    d[a][b], d[b][a] = t, t


for i in range(N):
    for j in range(N):
        for k in range(N):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])


ans = float('inf')
for i in permutations(r):
    temp = 0
    for j in range(R-1):
        temp += d[i[j]-1][i[j+1]-1]
        if temp > ans:
            break
    ans = min(ans, temp)

print(ans)

### FIXED CODE ###

from itertools import permutations

def main():
    N, M, R = map(int, input().split())
    r = map(int, input().split())
    inf = float('inf')
    d = [[inf] * N for i in range(N)]

    for i in range(N):
        d[i][i] = 0

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

    for k in range(N):
        for i in range(N):
            for j in range(N):
                temp = d[i][k] + d[k][j]
                if d[i][j] > temp:
                    d[i][j] = temp

    ans = inf
    for i in permutations(r):
        temp = 0
        for j in range(len(i)-1):
            temp += d[i[j] - 1][i[j + 1] - 1]
            if temp > ans:
                break
        if ans > temp:
            ans = temp

    print(ans)


main()
### BUGGY CODE ###

import sys
import numpy

N, X = map(int, input().split())
x_list = list(map(int, input().split()))
x_list.insert(0, 0)

sum_x = list(numpy.cumsum(x_list))

max_robo = -(-1 * N // 2)
ans = sys.maxsize
for k in range(1, max_robo + 1):
    t_ans = (N + k) * X
    t_ans += 5 * sum_x[N]
    for j in range(1, -(-(N - k) // k)):
        t_ans += 2 * sum_x[N - (j + 1) * k]

    ans = min(ans, t_ans)

print(ans)

### FIXED CODE ###

import sys
# import numpy

N, X = map(int, input().split())
x_list = list(map(int, input().split()))
x_list.insert(0, 0)

tmp = 0
sum_x = []
for x in x_list:
    tmp += x
    sum_x.append(tmp)
# sum_x = numpy.cumsum(x_list)

max_robo = -(-1 * N // 2)
ans = sys.maxsize
for k in range(1, max_robo + 1):
    t_ans = (N + k) * X + 5 * sum_x[N]
    for j in range(1, -(-(N - k) // k)):
        t_ans += 2 * sum_x[N - (j + 1) * k]

    ans = min(ans, t_ans)

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

def MAP(): return map(int,input().split())

n,q = MAP()
s = list(input())
lr = [input().split() for _ in range(q)]
AC_place =[]

for i in range(n-1):
    if s[i]+s[i+1]=="AC":
        AC_place.append(i)

for i in lr:
    tmp=0
    for j in range(int(i[0])-1,int(i[1])-1):
        if j in AC_place:
            tmp+=1
    print(tmp)

### FIXED CODE ###

def MAP(): return map(int,input().split())

n,q = MAP()
s = input()
t = [0]*(n+1)
for i in range(n):
    t[i+1] = t[i]+(1 if s[i:i+2]=="AC" else 0)
for i in range(q):
    l,r = MAP()
    print(t[r-1]-t[l-1])
### BUGGY CODE ###

L, R = [int(i) for i in input().split()]
min = 2018
for i in range(L,R):
    for j in range(i+1,R+1):
        mod = (i*j)%2019
        if(mod<min):
            min = mod
print("{}".format(min))

### FIXED CODE ###

L, R = [int(i) for i in input().split()]
min = 2018
for i in range(L,R):
    for j in range(i+1,R+1):
        mod = (i*j)%2019
        if mod<min:
            min = mod
        if mod==0:
            print("{}".format(mod))
            exit()
print("{}".format(min))
### BUGGY CODE ###

def main():
    N = int(input())
    S = input()
    m = 0
    for i in range(N-1):
        A = z_algo(S[i:])
        m = max(m, max(min(i,v) for i, v in enumerate(A)))
    return m

def z_algo(S):
    N = len(S)
    A = [0]*N
    i = 1; j = 0
    A[0] = l = len(S)
    while i < l:
        while i+j < l and S[j] == S[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    return A
print(main()) 


### FIXED CODE ###

def main():
    N = int(input())
    S = input()
    m = 0
    for i in range(N-1):
        A = z_algo(S[i:])
        m = max(m, max(min(i,v) for i, v in enumerate(A)))
    return m

def z_algo(S):
    N = len(S)
    A = [0]*N
    i = 1; j = 0
    A[0] = l = len(S)
    while i < l:
        while i+j < l and S[j] == S[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    return A
print(main())
### BUGGY CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    K = int(input())
    x = 0
    
    if K % 2 == 0 or K % 5 ==  0:
        print(-1)
        exit()
 
    for i in range(K):
        amari = (7 * 10 ** i) % K
        x = x + amari
        if x % K == 0:
            print(i + 1)
            break
        x = x % K
   


    

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    K = int(input())
    x = 0
    i = 0
    if K % 2 == 0 or K % 5 ==  0:
        print(-1)
        exit()
    
    while True:
        x = (x * 10 + 7) % K
        i += 1
        if x == 0:
            print(i)
            break


    

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

n = int(input())

while 1:
  lst = set(list(str(n)))
  if len(lst)==1:
    print(n)
  else:
    n+= 1
    

### FIXED CODE ###

n = int(input())
for i in range(1,10):
  if i*111 >= n:
    print(i*111)
    break
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)

N, Q = list(map(int, input().split()))
nodes = [[] for i in range(N)]
for i in range(N-1):
  r, e = list(map(int, input().split()))
  r, e = r - 1, e - 1
  nodes[r].append(e)
  nodes[e].append(r)
#print(nodes)

result = [0] * N
for i in range(Q):
  r, s = list(map(int, input().split()))
  result[r-1] += s

def dfs(r, prev=-1):
  for i in nodes[r]:
    if i == prev:
      continue
    result[i] += result[r]
    dfs(i, r)

dfs(0)
print(" ".join(map(str, result)))


### FIXED CODE ###

#人の（ほぼ同じなのにうまくいかないので）
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N, Q = map(int, input().split())
lines = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    lines[a-1].append(b-1)
    lines[b-1].append(a-1)
ans = [0]*N
for _ in range(Q):
    p, x = map(int, input().split())
    ans[p-1] += x

def dfs(v, parent):
    for u in lines[v]:
        if u != parent:
            ans[u] += ans[v]
            dfs(u, v)

dfs(0, -1)
print (*ans)
### BUGGY CODE ###

n = int(input())
an = list(map(int, input().split()))
check1 = []
check2 = []
ans = 0
for i, a in enumerate(an):
    check1.append(i+a)
    check2.append(i-a)
    if i-a in check1:
        ans += check1.count(i-a)
    if i+a in check2:
        ans += check2.count(i+a)
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 ###

# https://qiita.com/kazukazukazukazu/items/e5db00a3aefb1f5ed72f
import collections
import heapq


class Dijkstra():
    def __init__(self):
        self.e = collections.defaultdict(list)

    def add(self, u, v, d, directed=False):
        """
        #0-indexedでなくてもよいことに注意
        #u = from, v = to, d = cost
        #directed = Trueなら、有向グラフである
        """
        if directed is False:
            self.e[u].append([v, d])
            self.e[v].append([u, d])
        else:
            self.e[u].append([v, d])

    def delete(self, u, v):
        self.e[u] = [_ for _ in self.e[u] if _[0] != v]
        self.e[v] = [_ for _ in self.e[v] if _[0] != u]

    def Dijkstra_search(self, s):
        """
        #0-indexedでなくてもよいことに注意
        #:param s: 始点
        #:return: 始点から各点までの最短経路と最短経路を求めるのに必要なprev
        """
        d = collections.defaultdict(lambda: float('inf'))
        prev = collections.defaultdict(lambda: None)
        d[s] = 0
        q = []
        heapq.heappush(q, (0, s))
        v = collections.defaultdict(bool)
        while len(q):
            k, u = heapq.heappop(q)
            if v[u]:
                continue
            v[u] = True

            for uv, ud in self.e[u]:
                if v[uv]:
                    continue
                vd = k + ud
                if d[uv] > vd:
                    d[uv] = vd
                    prev[uv] = u
                    heapq.heappush(q, (vd, uv))

        return d, prev

    def getDijkstraShortestPath(self, start, goal):
        _, prev = self.Dijkstra_search(start)
        shortestPath = []
        node = goal
        while node is not None:
            shortestPath.append(node)
            node = prev[node]
        return shortestPath[::-1]

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

graph = Dijkstra()

for a, b in AB:
    graph.add(a, b, 1)

ans = []
for i in range(2, N+1):
    result = graph.getDijkstraShortestPath(i, 1)
    ans.append(result[1])
#     print(result[1])

if float('inf') in ans:
    print('No')
else:
    print('Yes')
    for a in ans:
        print(a)
    
    

### FIXED CODE ###

import collections
N, M = map(int, input().split())
G = collections.defaultdict(list)
for _ in range(M):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)
    
dist = [-1] * (N + 1)
que = collections.deque()

dist[1] = 0
que.append(1)

while len(que):
    v = que.popleft()
    for nv in G[v]:
        if dist[nv] != -1:
            continue
        dist[nv] = dist[v] + 1
        que.append(nv)

memo = collections.defaultdict(int)
memo[0] = 1

print('Yes')
for i in range(2, N+1):
    memo[dist[i]] = i
for dis in dist[2:]:
    print(memo[dis-1])
### BUGGY CODE ###

from decimal import *
getcontext().prec=3000
a,b,c=map(int,input().split())
print('Yes' if Decimal(a)**Decimal(0.5)+Decimal(b)**Decimal(0.5)<Decimal(c)**Decimal(0.5) else 'No')

### FIXED CODE ###

a,b,c=map(int,input().split())
print('Yes' if c-a-b>0 and 4*a*b<(c-a-b)**2 else 'No')