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

import sys,gc

class Deque:
    class Cell2:
        def __init__(self, x, y = None, z = None):
            self.data = x
            self.next = y
            self.prev = z

    def __init__(self):
        head = Deque.Cell2(None)
        head.next = head        
        head.prev = head
        self.size = 0
        self.head = head

    def push_front(self, x):
        h = self.head
        q = h.next
        p = Deque.Cell2(x, q, h)
        h.next = p
        q.prev = p
        self.size += 1

    def pop_back(self):
        gc.enable()
        if self.size == 0: raise IndexError
        h = self.head
        q = h.prev
        p = q.prev
        p.next = h
        h.prev = p
        self.size -= 1
        gc.disable()
        return q.data

    def pop_front(self):
        gc.enable()
        if self.size == 0: raise IndexError
        h = self.head
        q = h.next
        p = q.next
        p.prev = h
        h.next = p
        self.size -= 1
        gc.disable()
        return q.data

    def delete(self,x):
        gc.enable()
        h=self.head.next
        while h.data!=x:
            h=h.next
            if h==self.head: return
        q=h.next
        p=h.prev
        q.prev=p
        p.next=q
        self.size -= 1
        gc.disable()
        return

    def __str__(self):
        if self.size == 0: return
        buff = ''
        n = self.size
        cp = self.head.next
        while n > 1:
            buff += '%s ' % cp.data
            cp = cp.next
            n -= 1
        buff += '%s' % cp.data
        return buff
    
gc.disable()
A=Deque()
n=int(raw_input())
while n:
    s = (raw_input().split())
    if s[0] == 'insert':
        A.push_front(int(s[1]))
    elif s[0] == 'delete':
        A.delete(int(s[1]))
    elif s[0] == 'deleteFirst':
        A.pop_front()
    elif s[0] == 'deleteLast':
        A.pop_back()
    n -=1
    
print A

### FIXED CODE ###

import sys,gc
    
A=[]
fp =0
bp =0

n=int(raw_input())
while n:
    s = raw_input()
    if s[0] == 'i':
        A.append(int(s[7:]))
        fp += 1
    elif s[6] == ' ':
        try:
            i = A[::-1].index(int(s[7:]))
            if i!=-1:
                del A[-i-1]
                fp -=1
        except:
            pass
    elif s[6] == 'F':
        A.pop()
        fp -=1
    elif s[6] == 'L':
        bp +=1
    n -=1

for e in A[bp:fp+1][::-1]:
    print int(e),
### BUGGY CODE ###

n, k = list(map(int,input().split()))
a = list(map(int,input().split()))
# 循環を調べる
c=0
count=0
init_city=0
tmp_city = [0] * (n+1)

while (1):
    count+=1
#     print(c)
    tmp=a[c]
    if k==count:
        tmp_city.append(tmp)
        tmp_city=[1]+tmp_city
        break
    if tmp == 1:
        init_city=0
        tmp_city=[1]+tmp_city
        break
    if tmp in tmp_city:
        init_city=tmp_city.index(tmp)+1
        tmp_city=[1]+tmp_city
        break
    tmp_city[count-1]=tmp
    c=tmp-1
if k==count:
    print(tmp_city[-1])
else:
    print(tmp_city[init_city:count][(k-(init_city))%(count-init_city)])

### FIXED CODE ###

n, k = map(int, input().split())
A = list(map(int, input().split()))
D = [0] * (n+1)
now = 1
for i in range(1, k+1):
    tmp = A[now-1]
    if not D[tmp]:
        now = tmp
        D[now] += i
    else:
        pre = D[tmp]
        loop = i - D[tmp]
        if loop>1:
            now=D.index((k - pre) % loop + pre)
        else:
            now=tmp
        break
print(now)
### BUGGY CODE ###

n,m,k=map(int,input().split())
for i in range(k):
  if n>0:
    n-=1
  elif m>0:
    m-=1
  else:
    break
print(n,m)

### FIXED CODE ###

a,b,k=map(int,input().split())
if a>=k:
  print(a-k,b)
elif a+b>=k:
  print(0,a+b-k)
else:
  print(0,0)
### BUGGY CODE ###

import numpy as np
h, w, k = map(int, input().split())
s = []
for _ in range(h):
    s.append(list(map(int, list(input()))))
s = np.array(s)

def count(li):
    if np.max(li) > k:
        return -1
    tmp = np.zeros(len(li))
    cnt = 0
    for i in range(w):
        tmp += li[:, i]
        if np.max(tmp) > k:
            cnt += 1
            tmp = li[:, i]
    return cnt

ans = 1000000
for i in range(2**(h-1)):
    r = 0
    l = []
    for j in range(h-1):
        if (i>>j)&1:
            l.append(np.sum(s[r:j+1, :], axis=0))
            r = j+1
    l.append(np.sum(s[r:, :], axis=0))
    cnt = count(np.vstack(l))
    if cnt>=0:
        ans = min(ans, cnt+len(l)-1)
print(ans)


### FIXED CODE ###

import numpy as np
h, w, k = map(int, input().split())
s = []
for _ in range(h):
    s.append(list(map(int, list(input()))))
s = np.array(s)

def count(li):
    if np.max(li) > k:
        return -1
    tmp = np.zeros(len(li), dtype=int)
    cnt = len(li)-1
    for i in range(w):
        tmp += li[:, i]
        if np.max(tmp) > k:
            cnt += 1
            if cnt >= ans:
                return -1
            tmp = li[:, i]
    return cnt

ans = 1000000
for i in range(2**(h-1)):
    r = 0
    l = []
    for j in range(h-1):
        if (i>>j)&1:
            l.append(np.sum(s[r:j+1, :], axis=0))
            r = j+1
    l.append(np.sum(s[r:, :], axis=0))
    if ans <= len(l)-1:
        continue
    cnt = count(np.vstack(l))
    if cnt>=0:
        ans = min(ans, cnt)
print(ans)
### BUGGY CODE ###

from functools import reduce
import operator
_ = input()
M = reduce(operator.mul, [int(v) for v in input().split()])

print(M if M <= 10**18 else -1)

### FIXED CODE ###


_ = input()
N = sorted([int(v) for v in input().split()])
s = 1
for n in N:
    s *= n
    if s == 0 or s > 10**18:
        break

print(s if s <= 10**18 else -1)
### BUGGY CODE ###

from collections import deque

class Tree:
    def __init__(self, n, init_list, root=1):
        self.num = (n + 1)
        self.parents = [-1] * self.num
        self.first_child = [-1] * self.num
        self.next_child = [-1] * self.num
        self.check = [-1] * self.num
        self.g = {i: [] for i in range(1, self.num)}
        self.make_g(init_list, root)

    def make_g(self, con, root):
        m = len(con)
        for i in range(m):
            self.g[con[i][0]].append(con[i][1])
            self.g[con[i][1]].append(con[i][0])
        q = deque([root])
        while q:
            node = q.pop()
            self.check[node] = 1
            cnt = 0
            for i, sub_node in enumerate(self.g[node]):
                if self.check[sub_node] != -1:
                    continue
                if cnt == 0:
                    self.first_child[node] = sub_node
                self.parents[sub_node] = node
                if i != len(self.g[node])-1:
                    self.next_child[sub_node] = self.g[node][i+1]
                q.append(sub_node)
                cnt += 1

    def childs(self, node):
        child_list = []
        if self.first_child[node] != -1:
            child_list.append(self.first_child[node])
            node = self.first_child[node]
            while 1:
                if self.next_child[node] == -1:
                    break
                else:
                    child_list.append(self.next_child[node])
                node = self.next_child[node]
        return child_list

    def parent(self, n):
        return self.parents[n]


import sys
input = sys.stdin.readline
N, Q = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N-1)]
P = [0] * Q
X = [0] * Q
V = [0] * (N + 1)
for i in range(Q):
    P, X = map(int, input().split())
    V[P] += X

tr = Tree(N, AB)
# 800ms

q = deque()
q.extend(tr.childs(1))
while q:
    node = q.pop()
    V[node] += V[tr.parent(node)]
    tmp = tr.childs(node)
    if tmp:
        q.extendleft(tmp)

print(*V[1:])


### FIXED CODE ###

from collections import deque

N, Q = map(int, input().split())
AB = {i: set() for i in range(1, N+1)}
for i in range(N - 1):
    tmpA, tmpB = map(int, input().split())
    AB[tmpA].add(tmpB)
    AB[tmpB].add(tmpA)
P = [0] * Q
X = [0] * Q
V = [0] * (N + 1)
for i in range(Q):
    P, X = map(int, input().split())
    V[P] += X

check = [0]*(N + 1)
q = deque()
q.append(1)
check[1] = 1
while q != deque():
    node = q.pop()
    for i in AB[node]:
        if check[i] == 1:
            continue
        V[i] += V[node]
        check[i] = 1
        q.appendleft(i)
print(*V[1:])
### BUGGY CODE ###

n = int(input())

ls = list(map(int, input().split()))

rg = range(1, n + 1)

for i in rg:
    c = ls.count(i)
    print(c)
    if c != 0:
        ls.remove(i)


### FIXED CODE ###

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

ls2 =[0 for x in range(n)]
#0がn個のリストを用意する

for x in ls:
    ls2[x - 1] += 1

for x in range(n):
    print(ls2[x])
### BUGGY CODE ###

import sys
def main():
    input = sys.stdin.readline
    H,W = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(H)]
    B = [list(map(int, input().split())) for _ in range(H)]

    S = (80+80)*80//2
    dp = [[[0]*(S+1) for _ in range(W)] for __ in range(H)]
    dp[0][0][abs(A[0][0] - B[0][0])] = 1
    for i in range(H):
        for j in range(W):
            for s in range(S+1):
                if i < H-1:
                    ni = i + 1
                    nj = j
                    t = abs(A[ni][nj] - B[ni][nj])
                    ns = s + t
                    if ns <= S:
                        dp[ni][nj][ns] |= dp[i][j][s]
                    ns = abs(s - t)
                    dp[ni][nj][ns] |= dp[i][j][s]
                if j < W-1:
                    ni = i
                    nj = j + 1
                    t = abs(A[ni][nj] - B[ni][nj])
                    ns = s + t
                    if ns <= S:
                        dp[ni][nj][ns] |= dp[i][j][s]
                    ns = abs(s - t)
                    dp[ni][nj][ns] |= dp[i][j][s]
    for s in range(S+1):
        if dp[H-1][W-1][s]:
            print(s)
            break

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
def main():
    input = sys.stdin.readline
    H,W = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(H)]
    B = [list(map(int, input().split())) for _ in range(H)]
    C = [[abs(A[i][j] - B[i][j]) for j in range(W)] for i in range(H)]

    M = 160*80
    dp = [[0 for _ in range(W)] for __ in range(H)]
    dp[0][0] = 1 << (C[0][0] + M)
    for i in range(H):
        for j in range(W):
            for ni,nj in [(i,j+1),(i+1,j)]:
                if ni >= H or nj >= W: continue
                t = C[ni][nj]
                dp[ni][nj] |= dp[i][j] << t
                dp[ni][nj] |= dp[i][j] >> t
    
    a = dp[H-1][W-1]
    ans = 0
    while True:
        if a & (1 << (M+ans)) or a & (1 >> (M-ans)): break
        ans += 1
    print(ans)

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

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

t=0
c=0
for i in range(N):
    for j in range(i+1,N):
        t=A[i]+A[j]
        for k in range(j+1,N):
            if((max(A[i],A[j],A[k])*2)<(t+A[k])):
                c+=1
print(c)


### FIXED CODE ###

import bisect

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

t=0
c=0
for i in range(N-2):
    for j in range(i+1,N-1):
        t=A[i]+A[j]
        num=bisect.bisect_left(A,t)-1
        c+=max((num-j),0)

print(c)
### BUGGY CODE ###

N = int(input())
edge = [[] for _ in range(N)]
length = [[0 for _ in range(N)] for _ in range(N)]
for i in range(N-1):
  u,v,w = map(int,input().split())
  edge[u-1].append(v-1)
  edge[v-1].append(u-1)
  length[u-1][v-1] = w
  length[v-1][u-1] = w

#print(edge)
#print(length)

def bfs(u,v):
  for e in edge[u]:
    if e != v:
      ans[e] = (length[e][u] + ans[u]) % 2
      bfs(e,u)

ans = [0] * N
bfs(0,-1)
print(*ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 5)

N = int(input())
edge = [[] for _ in range(N)]
for i in range(N-1):
  u,v,w = map(int,input().split())
  u -= 1
  v -= 1
  edge[u].append((v,w))
  edge[v].append((u,w))

#print(edge)

def dfs(u,v):
  for e,w in edge[u]:
    if e != v:
      ans[e] = (w + ans[u]) % 2
      # print(ans)
      dfs(e,u)

ans = [0] + [-1] * (N-1)
dfs(0,-1)
print(*ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N,M = map(int,input().split())
H = list(map(int,input().split()))
L = [list(map(int,input().split())) for _ in range(M)]
ans = 0
for i in range(N):
    try:
        ls = set([j[0]-1 for j in L if i+1 in j] + [j[1]-1 for j in L if i+1 in j])
        h = [H[k] for k in ls]
        if max(h) == H[i] and h.count(max(h))==1:
            ans += 1
    except:
        ans += 1
print(ans)

### FIXED CODE ###

N,M = map(int,input().split())
H = list(map(int,input().split()))
L = [0] * N
for _ in range(M):
    a,b = map(int,input().split())
    if H[a-1] > H[b-1]:
        L[b-1] += 1
    elif H[a-1] < H[b-1]:
        L[a-1] += 1
    else:
        L[a-1] += 1
        L[b-1] += 1
ans = L.count(0)
print(ans)
### BUGGY CODE ###

N , M = map(int,input().split())
L = sorted(list(map(int,input().split())))
table =  [0,2,5,5,4,5,6,3,7,6]
L_val =sorted( list(map(lambda x:(table[x],x),L)))
number = ["0" for i in range(10**4+10)]

def comp(x,y):
    if len(x) >len(y):
        return 0
    elif len(x) < len(y):
        return 1
    else:
        for i in range(len(x)):
            if x[i] == y[i]:
                i+=1
            elif int(x[i]) < int(y[i]):
                return 1
            elif int(x[i]) > int(y[i]):
                return 0
        return 0



for x in L_val:
    number[x[0]] = str(x[1])

for i in range(10**4):
    tmp = number[i]
    if tmp=="0":
        continue
    for x in L_val:
        if  comp(number[i+x[0]],tmp + str(x[1])):
            number[i+x[0]] = tmp + str(x[1])

print(number[N])


### FIXED CODE ###

N , M = map(int,input().split())
L = sorted(list(map(int,input().split())))
table =  [0,2,5,5,4,5,6,3,7,6]
L_val =sorted( list(map(lambda x:(table[x],x),L)))
number = ["0" for i in range(10**4+10)]

def comp(x,y):
    if len(x) >len(y):
        return 0
    elif len(x) < len(y):
        return 1
    else:
        for i in range(len(x)):
            if x[i] == y[i]:
                i+=1
            elif int(x[i]) < int(y[i]):
                return 1
            elif int(x[i]) > int(y[i]):
                return 0
        return 0



for x in L_val:
    number[x[0]] = str(x[1])

for i in range(10**4):
    tmp = number[i]
    if tmp=="0":
        continue
    for x in L_val:
        if  comp(number[i+x[0]],tmp + str(x[1])):
            number[i+x[0]] = tmp + str(x[1])

print(number[N])
### BUGGY CODE ###

N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

dp = [[0] * (W + 1) for _ in range(N + 1)]
# dp[i][j](j=0,1,...,W)の値が求まっている状態で、dp[i+1][j]を更新することを考える
for i in range(N):
	for j in range(W + 1):
		# 品物(w[i],v[i])を選ぶとき、j-w[i]>=0に限って、価値v[i]が加算される
		if j - w[i] >= 0:
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i])
		# 品物(w[i],v[i])を選ばないとき、何も加算しない
		dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
print(dp[N][W])

### FIXED CODE ###

N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

dp = [[0] * (W + 1) for _ in range(N + 1)]
# dp[i][j](j=0,1,...,W)の値が求まっている状態で、dp[i+1][j]を更新することを考える
for i in range(N):
	for j in range(W + 1):
		# 品物(w[i],v[i])を選ぶとき、j-w[i]>=0に限って、価値v[i]が加算される
		if j - w[i] >= 0:
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i])
		# 品物(w[i],v[i])を選ばないとき、何も加算しない
		dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
print(dp[N][W])
### BUGGY CODE ###

import sys
import math

N = int(input())

str_list = list(map(int,input().split()))

sum0 = str_list[0]

for n in range(1,N):
    sum0 = sum0 * str_list[n]
if sum0 > 10**18:
    print('-1')
else:
    print(sum0)

### FIXED CODE ###

N = int(input())

str_list = list(map(int,input().split()))

sum0 = str_list[0]

for n in range(0,N):
    if str_list[n] == 0:
        sum0 = 0

for n in range(1,N):
    if sum0 == 0:
        break
    sum0 = sum0 * str_list[n]
    if sum0 > 10 ** 18:
        sum0 = -1
        break

print(sum0)
### BUGGY CODE ###

import sys
input = sys.stdin.buffer.readline

def main():
    n, w = map(int,input().split())
    wei = []
    val = []
    for i in range(n):
        a, b = map(int,input().split())
        wei.append(a)
        val.append(b)

    max_v = 10**5 + 10
    dp = [[float('inf') for i in range(max_v)] for j in range(100+10)]

    dp[0][0] = 0

    for i in range(n):
        for sum_v in range(max_v):

            # i 番目の品物を選ぶ場合
            if sum_v - val[i] >= 0:
                dp[i+1][sum_v] = min(dp[i][sum_v], dp[i][sum_v - val[i]] + wei[i])
            else:
                # i 番目の品物を選ばない場合
                dp[i+1][sum_v] = dp[i][sum_v]

    res = 0
    for i in range(100+10):
        for sum_v in range(max_v):
            if dp[i][sum_v] <= w and res < sum_v:
                res = sum_v

    print(res)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

def main():
    n, w = map(int,input().split())
    wei = []
    val = []
    for i in range(n):
        a, b = map(int,input().split())
        wei.append(a)
        val.append(b)

    max_v = 10**5 + 10
    dp = [[float('inf') for i in range(max_v)] for j in range(100+10)]

    dp[0][0] = 0

    for i in range(n):
        for sum_v in range(max_v):

            # i 番目の品物を選ぶ場合
            if sum_v - val[i] >= 0:
                dp[i+1][sum_v] = min(dp[i][sum_v], dp[i][sum_v - val[i]] + wei[i])
            else:
                # i 番目の品物を選ばない場合
                dp[i+1][sum_v] = dp[i][sum_v]

    res = 0
    for i in range(100+10):
        for sum_v in range(max_v):
            if dp[i][sum_v] <= w and res < sum_v:
                res = sum_v

    print(res)

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

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(1000000000)

N = int(input())
MOD = 10**9 + 7

neighbor = [[] for _ in range(N)]
for _ in range(N-1):
    x,y = map(int, input().split())
    neighbor[x-1].append(y-1)
    neighbor[y-1].append(x-1)

memo = [[-1]*2 for _ in range(N)]

def dp(node, color, parent):
    if memo[node][color] != -1:
        return memo[node][color]
    output = 1
    for child in neighbor[node]:
        if child == parent:
            pass
        else:
            tmp = dp(child, 0, node)
            if color == 0:
                tmp += dp(child, 1, node)
            output *= tmp
    output %= MOD
    memo[node][color] = output
    return output

print((dp(0,0,-1) + dp(0,1,-1)) % MOD)

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(1000000000)

N, *XY = map(int,open(0).read().split())
MOD = 10**9 + 7

neighbor = [[] for _ in range(N)]
for x,y in zip(*[iter(XY)]*2):
    neighbor[x-1] += y-1,
    neighbor[y-1] += x-1,

parent = {0}

def dp(node):
    black_output = white_output = 1
    for child in neighbor[node]:
        if child in parent:
            continue
        else:
            parent.add(child)
            tmp_black, tmp_white = dp(child)
            black_output *= tmp_white
            white_output *= tmp_black + tmp_white
    black_output %= MOD
    white_output %= MOD
    return black_output, white_output

print(sum(dp(0)) % MOD)
### BUGGY CODE ###



def check(goal, dist_data, start):
    dp = [[0 for i in range(17000)] for i in range(len(dist_data) + 1)]
    dp[0][start + 8500] = 1

    for i in range(1, len(dist_data) + 1):
        for j in range(len(dp[i - 1])):
            if dp[i - 1][j]:
                dp[i][j + dist_data[i - 1]] = 1
                dp[i][j - dist_data[i - 1]] = 1

    return dp[len(dist_data)][goal + 8500]


def main():
    data = input()
    goal = list(map(int, input().split()))
    data = data.split('T')
    move_dist = [len(ele) for ele in data]

    x_data = move_dist[2::2]
    y_data = move_dist[1::2]

    if check(goal[0], x_data, move_dist[0]) and check(goal[1], y_data, 0):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

### FIXED CODE ###



def check(goal, dist_data, start):
    dp_now = [0 for i in range(17000)]
    dp_now[start + 8500] = 1
    dp_next = [0 for i in range(17000)]

    for i in range(len(dist_data)):
        for j in range(len(dp_now)):
            if dp_now[j]:
                dp_next[j + dist_data[i]] = 1
                dp_next[j - dist_data[i]] = 1
        dp_now = dp_next
        dp_next = [0 for i in range(17000)]

    return dp_now[goal + 8500]


def main():
    data = input()
    goal = list(map(int, input().split()))
    data = data.split('T')
    move_dist = [len(ele) for ele in data]

    x_data = move_dist[2::2]
    y_data = move_dist[1::2]

    if check(goal[0], x_data, move_dist[0]) and check(goal[1], y_data, 0):
        print('Yes')
    else:
        print('No')


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

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

lr = [tuple(int(x) for x in input().split()) for _ in range(m)]
pq = [tuple(int(x) for x in input().split()) for _ in range(q)]

for p, q in pq:
    print(sum(p <= l and q >= r for l, r in lr))

### FIXED CODE ###

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

temp = [ [0 for _ in range(n)] for _ in range(n)]
tables = [ [0 for _ in range(n)] for _ in range(n)]

if n == 1:
    print('1')
    exit()

for _ in range(m):
    l, r = map(int, input().split())
    temp[l - 1][r - 1] += 1

pq = [tuple(int(x) - 1 for x in input().split()) for _ in range(q)]

hoge = 0
for j in range(n):
    hoge += temp[0][j]
    tables[0][j] = hoge

for i in range(1, n):
    hoge = 0
    for j in range(n):
        hoge += temp[i][j]
        tables[i][j] = tables[i - 1][j] + hoge

for p, q in pq:
    if p == 0:
        print(tables[q][q])
    else:
        print(tables[q][q] - tables[p - 1][q] - tables[q][p - 1] + tables[p - 1][p - 1] )
### BUGGY CODE ###


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

path = [[] for i in range(N)]
indicator = [None] * N
indicator[0] = (0, 0)
for i in range(M):
    a, b = map(int, input().split())
    a-=1
    b-=1
    path[a].append(b)
    path[b].append(a)

def solve(path, indicator):
    visit = set()
    visit.add(0)
    p = 0
    l = 0

    q = [(0, 0)]

    while q:
        (p, l), q = q[0], q[1:]
        for room in path[p]:
            if room in visit:
                continue
            if indicator[room] is None:
                indicator[room] = (p, l+1)
                q.append((room, l+1))
            elif indicator[room][1] > l+1:
                return []
            visit.add(room)
L = solve(path, indicator)
if L == []:
    print("No")
else:
    print("Yes")
    for p, l in indicator[1:]:
        print(p+1)







### FIXED CODE ###

from collections import deque
N, M = map(int, input().split())

path = [[] for i in range(N)]
indicator = [None] * N
indicator[0] = (0, 0)
for i in range(M):
    a, b = map(int, input().split())
    a-=1
    b-=1
    path[a].append(b)
    path[b].append(a)

def solve(N, path, indicator):
    visit = [False]*N
    visit[0] = True
    p = 0
    l = 0
    q = deque()
    q.append((0, 0))

    while q:
        (p, l) = q.popleft()
        for room in path[p]:
            if visit[room]:
                continue
            if indicator[room] is None:
                indicator[room] = (p, l+1)
                q.append((room, l+1))
                visit[room] = True
            elif indicator[room][1] > l+1:
                return []

L = solve(N, path, indicator)
if L == []:
    print("No")
else:
    print("Yes")
    for p, l in indicator[1:]:
        print(p+1)