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

# 17:02-17:26
MOD = pow(10,9)+7
S = input()[::-1]
N = len(S)

F = [0]*N
for i in range(N):
    F[i] = pow(10,i,13)
D = [[[0]*13 for j in range(10)] for i in range(N)]
for i in range(N):
    if S[i]=="?":
        for j in range(10):
            k = (F[i]*j)%13
            if i==0:
                D[i][j][k] = 1
            else:
                for l in range(10):
                    for m in range(13):
                        D[i][j][(m+k)%13] += D[i-1][l][m]%MOD
    else:
        j = int(S[i])
        k = (F[i]*j)%13
        if i==0:
            D[i][j][k] = 1
        else:
            for l in range(10):
                for m in range(13):
                    D[i][j][(m+k)%13] += D[i-1][l][m]%MOD
ans = 0
for j in range(10):
    ans += D[N-1][j][5]
print(ans%MOD)

### FIXED CODE ###

MOD = pow(10,9)+7
S = input()[::-1]
N = len(S)

DP = [[0]*13 for i in range(N)]
K = 1
for i in range(N):
    if S[i]=="?":
        for j in range(10):
            if i==0:
                DP[0][(j*K)%13] = 1
            else:
                for k in range(13):
                    DP[i][(j*K+k)%13] += DP[i-1][k]
    else:
        j = int(S[i])*K
        if i==0:
            DP[0][(j*K)%13] = 1
        else:
            for k in range(13):
                DP[i][(j+k)%13] += DP[i-1][k]
    K = (K*10)%13
    for j in range(13):
        DP[i][j] = DP[i][j]%MOD
print(DP[N-1][5]%MOD)
### BUGGY CODE ###

n = int(input())
xarray = list(map(int,input().split()))
newArray = xarray[:]
newArray.sort()


for item in xarray:
    if newArray.index(item)<=int(n/2-1):
        print(newArray[int(n/2)])
    else:
        print(newArray[int(n/2)-1])

### FIXED CODE ###

n = int(input())
xarray = list(map(int,input().split()))
newArray = xarray[:]
newArray.sort()

left = newArray[n//2-1]
right = newArray[n//2]


for item in xarray:
    if item<=left:
        print(right)
    else:
        print(left)
### BUGGY CODE ###

def main():
    (l, r) = list(map(int, input().split()))

    min = 2020
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            if j - i > 2020:
                min = 0
                break
            mod = i * j % 2019
            if mod <= min:
                min = mod

            if min == 0:
                break

        else:
            if min == 0:
                break

    print(min)

if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    (l, r) = list(map(int, input().split()))

    ans = 2020
    for i in range(l, min(r + 1, l + 2019)):
        for j in range(i + 1, min(r + 1, i + 2020)):
            mod = i * j % 2019
            if mod <= ans:
                ans = mod

    print(ans)

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

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

limit_sum = sum(sorted(p_list, reverse=True)[:3])

scope_index = -1
max_sum = 0
for p_i in range(len(p_list)):
    now_sum = 0
    for i in range(k):
        if len(p_list) <= (p_i + i):
            break
        now_sum += p_list[p_i + i]

    if limit_sum == now_sum:
        max_sum = now_sum
        scope_index = p_i
        break

    if max_sum < now_sum:
        max_sum = now_sum
        scope_index = p_i

max_scope_list = p_list[scope_index:scope_index + k]
ex = 0
for scope in max_scope_list:
    for num in range(1, scope+1):
        ex += num*1/scope
print(ex)


### FIXED CODE ###

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

scope_index = 0
max_sum = 0
for i in range(k):
    max_sum += p_list[i]

now_sum = max_sum
for p_i in range(k, len(p_list)):
    now_sum -= p_list[p_i - k]
    now_sum += p_list[p_i]

    if max_sum < now_sum:
        scope_index = p_i
        max_sum = now_sum

ex = (max_sum+k)/2
print(ex)
### BUGGY CODE ###

import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

n = int(input())
a = list(map(int, input().split()))
ans = [0 for i in range(n)]
ball = []

for ii in range(n):
    #print(ans)
    i = n-ii
    if(a[i-1]!=ans[i-1]):
        d = make_divisors(i)
        ball.append(i)
        for k in d:
            ans[k-1] = 1-ans[k-1]
print(len(ball))
print(' '.join(map(str,ball)))

### FIXED CODE ###

import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

n = int(input())
a = list(map(int, input().split()))
ans = [0 for i in range(n)]
ball = []

for ii in range(n):
    #print(ans)
    i = n-ii
    if(a[i-1]!=ans[i-1]):
        d = make_divisors(i)
        ball.append(i)
        for k in d:
            ans[k-1] = 1-ans[k-1]
print(len(ball))
print(' '.join(map(str,ball)))
### BUGGY CODE ###

# seishin.py
from collections import deque
N = int(input())
*P, = map(int, input().split())
MOD = 10**9 + 7

G = [[] for i in range(N+1)]
for i, p in enumerate(P):
    G[p].append(i+1)
Q = [None]*(N+1)
for i in range(N, -1, -1):
    # i+1 <- P[i]
    Q[i] = q = deque([[1, 1, 0, 1]])

    # 子ノードのdequeを集める
    R = []
    for j in G[i]:
        R.append(Q[j])

    if R:
        R.sort(key=len, reverse=1)

        # dequeの小さい方から大きい方へマージする処理
        last = R.pop()
        while R:
            nxt = R.pop()
            for k in range(len(last)):
                a0, a1, a2, c0 = last.popleft()
                b0, b1, b2, c1 = nxt[k]
                nxt[k] = [a0*b0 % MOD, (a0*b1 + a1*b0) % MOD, (a0*b2 + a1*b1 + a2*b0 + a1*b2 + a2*b2 + a2*b1) % MOD, c0+c1]
            last = nxt
        # a0 <- a2
        for e in last:
            e[0] += e[2]
            e[2] = 0
        q.extend(last)
ans = 0
for a0, a1, a2, c in Q[0]:
    ans += pow(2, N+1-c, MOD) * a1 % MOD
print(ans % MOD)


### FIXED CODE ###

# seishin.py
from collections import deque
N = int(input())
*P, = map(int, input().split())
MOD = 10**9 + 7

G = [[] for i in range(N+1)]
U = [0]*(N+1)
C = [0]*(N+1)
for i, p in enumerate(P):
    G[p].append(i+1)
    U[i+1] = u = U[p]+1
    C[u] += 1
Q = [None]*(N+1)
PP = {}
def pp(k):
    if k not in PP:
        PP[k] = p = pow(2, k, MOD)
        return p
    return PP[k]
L = [0]*(N+1)

ept = []
sz = L.__getitem__
for i in range(N, -1, -1):
    g = G[i]
    if not g:
        continue

    # 子ノードのdequeを集める
    g.sort(key=sz, reverse=1)
    k = len(g)
    e = [pp(k) - k, k, 0]

    g0 = g[0]
    L[i] = L[g0] + 1
    if L[g0] == 0:
        Q[i] = deque([e])
        continue
    Q[i] = R = Q[g0]
    if k > 1:
        # a0 <- a2
        for s, r in zip(Q[g[1]] or ept, R):
            r[0] += r[2]; r[2] = 0

        for j in g[1:]:
            S = Q[j]
            if not S:
                break

            # dequeの小さい方から大きい方へマージする処理
            for (a0, a1, a2), r in zip(S, R):
                b0, b1, b2 = r; a0 += a2
                r[0] = a0*b0 % MOD
                r[1] = (a0*b1 + a1*b0) % MOD
                r[2] = ((a0+a1)*b2 + a1*b1) % MOD
    R.appendleft(e)
print((pp(N) + sum(pp(N+1-c) * a1 % MOD for (a0, a1, a2), c in zip(Q[0], C[1:]))) % MOD)
### BUGGY CODE ###

N,M=map(int,input().split())
P=[[] for i in range(N+1)]
Y=[]
id=[0 for i in range(M)]
for i in range(M):
    a,b=map(int,input().split())
    P[a].append(b)
    Y.append(b)
for i in range(N+1):
    P[i].sort()
for i in range(1,N+1):
    j=1
    for p in P[i]:
        id[Y.index(p)]=str(i*1000000+j)
        j+=1
for i in range(M):
    print(id[i].zfill(12))


### FIXED CODE ###

N,M=map(int,input().split())
P=[[] for i in range(M)]
Y=[1 for i in range(N+1)]
for i in range(M):
    a,b=map(int,input().split())
    P[i].append(i)
    P[i].append(a)
    P[i].append(b)
P.sort(key=lambda x:x[2])
for i in range(M):
    P[i].append(str(P[i][1]*1000000+Y[P[i][1]]))
    Y[P[i][1]]+=1
P.sort(key=lambda x:x[0])
for i in range(M):
    print(P[i][3].zfill(12))
### BUGGY CODE ###

def resolve():
    '''
    code here
    '''
    N, K = [int(item) for item in input().split()]
    A_list = [int(item) for item in input().split()]
    order_dict = dict(zip(range(1,N+1),A_list))

    foot_print = []

    goto = 1
    for i in range(N):
        if goto in foot_print:
            break
        else:
            foot_print.append(goto)
            goto = order_dict[goto]
    else:
        goto = 1

    foot_print2 = []
    for i in range(N):
        if goto in foot_print2:
            break
        else:
            foot_print2.append(goto)
            goto = order_dict[goto]
    else:
        goto = 1

    if K > len(foot_print):
        temp_num = K -len(foot_print)
        temp_num = temp_num % len(foot_print2)
        for i in range(temp_num):
            goto = order_dict[goto]

    else:
        goto = 1
        for i in range(K):
            goto = order_dict[goto]

    print(goto)
if __name__ == "__main__":
    resolve()


### FIXED CODE ###

def resolve():
    '''
    code here
    '''
    import collections
    N, K = [int(item) for item in input().split()]
    A_list = [int(item) for item in input().split()]
    order_dict = dict(zip(range(1,N+1),A_list))

    foot_print = [-1 for _ in range(N+1)]
    loop_que = collections.deque([1])

    goto = 1

    while foot_print[goto] == -1:
        foot_print[goto] = 1
        goto = order_dict[goto]
        loop_que.append(goto) 

    loop_start = loop_que.index(goto) + 1
    loop_len = len(loop_que) - loop_start

    # print(loop_que)
    # print(loop_start, loop_len)


    data_list = list(loop_que)
    if K >= len(loop_que):
        temp_K = K - loop_start + 1
        temp_K %= loop_len
        temp_loop = data_list[loop_start-1:-1]
        print(temp_loop[temp_K])
    else:

        print(data_list[K])

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

from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n = I()
L  = sorted(LI())
ret = 0
for i in range(n):
    for j in range(i + 1, n):
        ret += bisect_left(L[j + 1:], L[i] + L[j]) - bisect_right(L[j + 1:], abs(L[i] - L[j]))
        a = L[j + 1:]


print(ret)

### FIXED CODE ###

from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n = I()
L  = sorted(LI())
ret = 0
for i in range(n):
    for j in range(i + 1, n):
        ret += bisect_left(L, L[i] + L[j]) - j - 1

print(ret)
### BUGGY CODE ###

n = int(input())
a = []
for i in range(n):
    a1 = list(map(int,input().split()))
    a.append(a1)
l = [0 for i in range(n)]
l1 = [0 for i in range(n)]
day = 0
count1 = 0
count2 = 0
key = 1
b = n*(n-1)//2
while count1 < b:
    for i in range(n-1):
        if l[i] < n-1 and l1[i] == 0:
            j = a[i][l[i]] - 1
            if l1[j] == 0:
                if a[j][l[j]] == i + 1:
                    count1 += 1
                    l[i] += 1
                    l[j] += 1
                    l1[i] += 1
                    l1[j] += 1
    if count1 > count2:
        day += 1
        count2 = count1
        l1 = [0 for i in range(n)]
    else:
        key = 0
        break
if key == 1:
    print(day)
else:
    print(-1)

### FIXED CODE ###

from collections import deque
n = int(input())
a = []
for i in range(n):
    a1 = list(map(int,input().split()))
    a.append(a1)
l = [[[] for i in range(n)] for i in range(n)]
c = 0
day = 0
for i in range(n):
    ap = [i,a[i][0]-1]
    ap.sort()
    for j in range(1,n-1):
        p = [i,a[i][j]-1]
        p.sort()
        l[ap[0]][ap[1]].append(p)
        ap = p
rl = [[0 for i in range(n)] for i in range(n)]
dl = [[0 for i in range(n)] for i in range(n)]
d = deque()
for i in range(n):
    for j in range(n):
        if i < j:
            if len(l[i][j]) > 0:
                for k in l[i][j]:
                    rl[k[0]][k[1]] += 1
#print(rl)
for i in range(n):
    for j in range(n):
        if i < j:
            if rl[i][j] == 0:
                d.append([[i,j],0])
al = []
key = 0
#print(l)
if len(d) == 0:
    key = 1
while len(d):
    #print(d)
    now,day = d.pop()
    day += 1
    if len(l[now[0]][now[1]]) == 0:
        al.append(day)
    else:
        for i in l[now[0]][now[1]]:
            if rl[i[0]][i[1]] == 1:
                rl[i[0]][i[1]] -= 1
                d.append([i,max(day,dl[i[0]][i[1]])])
            else:
                rl[i[0]][i[1]] -= 1
                dl[i[0]][i[1]] = max(day,dl[i[0]][i[1]])
    if day > n*(n-1)//2:
        key = 1
        break
md = 0
for i in range(n):
    md += sum(rl[i])
if key == 1 or md > 0:
    print(-1)
else:
    print(max(al))
### BUGGY CODE ###

n=int(input())
A=[i+1 for i in range(n)]
print(sum(A)-n)

### FIXED CODE ###

n=int(input())
print((n-1)*(n-2)//2+(n-1))
### BUGGY CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


h,w = list(map(int, input().split()))
n = int(input())
from collections import defaultdict
mind = [10**15] * h
dw = defaultdict(list)
for i in range(n):
    r,c,a = map(int, input().split())
    r -= 1
    c -= 1
    mind[r] = min(mind[r], a)
    dw[c].append((a,r))
# 0未満になる要素があるか判定
es = [[] for _ in range(h)]
def main():
    ans = True
    for c in range(w):
        if len(dw[c])<=1:
            continue
        dw[c].sort()
        tmp = 0
        for i in range(len(dw[c])-1):
            u = dw[c][i][1]
            v = dw[c][i+1][1]
            val = dw[c][i+1][0] - dw[c][i][0]
            es[u].append((val, v))
            es[v].append((-val, u))
            tmp += val
            if mind[v]<tmp:
                return False
#     print(es)
#     print(dw)
    vals = [None]*h
    for start in range(h):
        if vals[start] is not None:
            continue
        q = [start]
        vals[start] = 0
        while q:
            u = q.pop()
            for d,v in es[u]:
                if vals[v] is None:
                    vals[v] = vals[u] + d
                    q.append(v)
                elif vals[v]!=vals[u]+d:
                    return False
                else:
                    q.append(v)
    return True
ans = main()
if ans:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


h,w = list(map(int, input().split()))
n = int(input())
from collections import defaultdict
mind = [10**15] * h
dw = defaultdict(list)
for i in range(n):
    r,c,a = map(int, input().split())
    r -= 1
    c -= 1
    mind[r] = min(mind[r], a)
    dw[c].append((a,r))
# 0未満になる要素があるか判定
es = [[] for _ in range(h)]
def main():
    ans = True
    for c in range(w):
        if len(dw[c])<=1:
            continue
        dw[c].sort()
        tmp = 0
        for i in range(len(dw[c])-1):
            u = dw[c][i][1]
            v = dw[c][i+1][1]
            val = dw[c][i+1][0] - dw[c][i][0]
            es[u].append((val, v))
            es[v].append((-val, u))
            tmp += val
            if mind[v]<tmp:
                return False
#     print(es)
#     print(dw)
    vals = [None]*h
    for start in range(h):
        if vals[start] is not None:
            continue
        q = [start]
        vals[start] = 0
        l = [(0, mind[start])]
        while q:
            u = q.pop()
            for d,v in es[u]:
                if vals[v] is None:
                    vals[v] = vals[u] + d
                    l.append((vals[v], mind[v]))
                    q.append(v)
                elif vals[v]!=vals[u]+d:
                    return False
        l.sort()
        for i in range(len(l)):
            if l[i][1]<l[i][0]-l[0][0]:
                return False
#     for u in range(h):
#         for d,v in es[u]:
#             if vals[u]+d!=vals[v]:
#                 return False
    return True
ans = main()
if ans:
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

s = input()

d = ["z"*5010]*5

for i in range(len(s)):
    for j in range(i, len(s)):
        x = s[i:j+1]
        if x in d or x == '':
            continue
        k = 0
        while k < 5 and x > d[k]:
            k += 1
        # print(k, d[0:k], x, d[k:])
        d = d[0:k] + [x] + d[k:]
        d = d[0:5]
        # print(f"->{d}")
# l = list(d)
# l.sort()
# print(l)
# if l[0] == '':
    # l = l[1:]

k = int(input())
print(d[k-1])


### FIXED CODE ###

s = input()

d = ["z"*5010]*5

k = int(input())
for i in range(len(s)):
    for j in range(i, i+k):
        x = s[i:j+1]
        if x in d or x == '':
            continue
        l = 0
        while l < 5 and x > d[l]:
            l += 1
        # print(k, d[0:k], x, d[k:])
        if l < 5:
            d = d[0:l] + [x] + d[l:]
            d = d[0:5]
        # print(f"->{d}")
# l = list(d)
# l.sort()
# print(l)
# if l[0] == '':
    # l = l[1:]

print(d[k-1])
### BUGGY CODE ###

from bisect import bisect_left, bisect_right

N, K = map(int, input().split())
As = sorted(map(int, input().split()))
        
l = - (10 ** 18 + 10)
r = 10 ** 18 + 10
while r - l > 1:
    mid = (l + r) // 2
    count = 0
    for i, A in enumerate(As):
        if A > 0:
            count += bisect_right(As, mid//A, lo = i+1) - (i+1)
        elif A < 0:
            count += N - bisect_left(As, -((-mid)//A), lo = i+1)
        else:
            if mid >= 0:
                count += N - i - 1
    if count < K:
        l = mid
    else:
        r = mid

print(r)


### FIXED CODE ###

from bisect import bisect_left, bisect_right

N, K = map(int, input().split())
As = sorted(map(int, input().split()))
        
l = - (10 ** 18 + 10)
r = 10 ** 18 + 10
while True:
    mid = (l + r) // 2
    count = 0
    for i, A in enumerate(As):
        if A > 0:
            count += bisect_right(As, mid//A, lo = i+1) - (i+1)
        elif A < 0:
            count += N - bisect_left(As, -((-mid)//A), lo = i+1)
        else:
            if mid >= 0:
                count += N - i - 1
    if count < K:
        l = mid
    else:
        r = mid
    if r - l == 1:
        break

print(r)
### BUGGY CODE ###

n,m = (int(i) for i in input().split())
x,y = [[] for i in range(n+1)],[1]*(n+1)
for i in range(n+m-1):
    a,b = (int(i) for i in input().split())
    x[a].append(b)
    y[b] = 0
for i in range(1,n+1):
    if y[i]: break
r,ans,q = i,[0]*(n+1),[i]
while q:
    p = q.pop()
    for i in x[p]:
        q.append(i)
        ans[i] = p
for i in ans[1:]: print(i)

### FIXED CODE ###

n,m = (int(i) for i in input().split())
x,y = [[] for i in range(n+1)],[0]*(n+1)
y[0] = 1
for i in range(n+m-1):
    a,b = (int(i) for i in input().split())
    x[a].append(b)
    y[b]+=1
ans,q = [0]*(n+1),[y.index(0)]
while q:
    p = q.pop()
    for i in x[p]:
        y[i]-=1
        if not y[i]:
            q.append(i)
            ans[i] = p
for i in ans[1:]: print(i)
### BUGGY CODE ###

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

# 奇数番目は1のカタマリの人数　偶数番目は0のカタマリの人数 両端は必ず1のカタマリの人数
now_state, now_count = '1', 0
L = []
for i in range(len(S)):
  if S[i] == now_state:
    now_count += 1
  else:
    L.append(now_count)
    # reset
    now_count = 1
    now_state = '1' if now_state == '0' else '0'
L.append(now_count)
if now_state == '0':
  L.append(0)

#print(L)
# 0の塊をj個ひっくり返す
# j==1のとき101の3個の和の最大
# j==2のとき10101の5個の和の最大
# j==jのとき101...1のj*2+1個の和の最大

def ngram(n, _list):
  return [_list[i:i+n] for i in range(len(_list)-n+1)]

now_max = 0
for j in range(0,K+1):
  tmp = ngram(j*2+1, L)
  # 偶数番目だけ
  tmp = [sum(tmp[i]) for i in range(len(tmp)) if i%2 == 0]
  tmp = max(tmp) if len(tmp) > 0 else 0
  #print(tmp)
  #tmp = [sum(t) for t in tmp]
  #print(tmp)
  #tmp = max(tmp)
  #print(j,tmp)
  now_max = max(tmp, now_max)
print(now_max)





### FIXED CODE ###

N,K = map(int, input().strip().split(' '))
S = input().strip()
l,r,now_max,now_zeros = 0,0,1,0
for r in range(1,N):
  if S[r-1] == '0':
    if S[r] == '0':
      continue
    else:
      now_zeros += 1
  else:
    if S[r] == '0':
      if now_zeros < K:
        continue
      else:
        now_max = max(r-l, now_max)
        now_zeros -= 1
        for _ in range(l,r):
          l += 1
          if S[l-1:l+1] == '01':
            break
    else:
      continue
now_max = max(r-l+1, now_max)
print(now_max)
### BUGGY CODE ###

from fractions import gcd
A,B=map(int,input().split())
gcd_list=[]
so_list=[]
for num in range(1,gcd(A,B)+1):
    if A%num==0 and B%num==0:
        gcd_list.append(num)
for i in gcd_list:
    flag=0
    if len(so_list)==0:
        so_list.append(i)
    else:
        for num in so_list:
            if num==1:
                continue
            if i%num==0:
                flag=1
                break
        if flag==0:
            so_list.append(i)
print(len(so_list))


### FIXED CODE ###

from math import gcd
A, B = map(int,input().split())
max_cmn_div = gcd(A, B)

# 約数列挙関数
def make_divisor(n):
    divisor = []
    for i in range(1, int(n**(1/2))+1):
        if n % i == 0:
            divisor.append(i)
            if i != n//i:
                divisor.append(n//i)
    return divisor

def check_prime(n):
    for i in range(2, int(n**(1/2))+1):
        if n % i == 0:
            return 0
    return 1

cmn_div = make_divisor(max_cmn_div)
ans = 0
for i in cmn_div:
    if check_prime(i):
        ans += 1
print(ans)
### BUGGY CODE ###

n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(m)]
ikeruheya = [[] for i in range(n)]
ans = [0]*(n+1)
#check = [0]*n
#check[0]=1
ans[0]=-1
ans[1]=1
for i in range(m):
    ikeruheya[a[i][0]-1].append(a[i][1])
    ikeruheya[a[i][1]-1].append(a[i][0])

    
next=[1]
count = 1
while any(ans[i] == 0 for i in range(n+1)):
    imaheya = next.pop(0)
    for j in range(len(ikeruheya[imaheya-1])):
        
        if ans[ikeruheya[imaheya-1][j]]==0:
            ans[ikeruheya[imaheya-1][j]]= imaheya 
            #check[ikeruheya[imaheya-1][j]-1] = 1
            next.append(ikeruheya[imaheya-1][j])
        
            
print("Yes")
for i in range(2, n+1):
    print(ans[i])


    
    


### FIXED CODE ###

from collections import deque
n,m = map(int,input().split())
a=[list(map(int, input().split())) for i in range(m)]
b=[[] for j in range(n)] 

michi=[-1]*(n)
michi[0]=0
heya=[]


for i in range(m):
    b[a[i][0]-1].append(a[i][1])
    b[a[i][1]-1].append(a[i][0])



heya.append(1)


while len(heya):
    now=heya.pop(0)-1
    
    for i in range(len(b[now])):
        if michi[b[now][i]-1] == -1:
            heya.append(b[now][i])
            michi[b[now][i]-1] = now+1
print("Yes")
for i in range(1,n):
    print(michi[i])