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

class Unionfind():
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]
    def find(self, x):
        while(self.table[x] >= 0):
            x = self.table[x]
        return x
    def union(self, x, y):
        xl = self.find(x)
        yl = self.find(y)
        if xl != yl:
            if self.table[xl] <= self.table[yl]:
                self.table[yl] = xl
                self.table[xl] -= 1
            else:
                self.table[xl] = yl
                self.table[yl] -= 1
n, m = map(int, input().split())
p = list(map(int, input().split()))
edges = [tuple(map(int, input().split())) for _ in range(m)]
place = Unionfind(n)
d = {}
for x, y in edges:
    place.union(x-1, y-1)
loot = [0] * n
for i in range(n):
    loot[i] = place.find(i)
    if loot[i] not in d:
        d[loot[i]] = [p[i]-1]
    else:
        d[loot[i]].append(p[i]-1)
counter = 0
for i in range(n):
    if i in d[loot[i]]:
        counter += 1
print(counter)


### FIXED CODE ###

class Unionfind():
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]
    def find(self, x):
        while(self.table[x] >= 0):
            x = self.table[x]
        return x
    def union(self, x, y):
        xl = self.find(x)
        yl = self.find(y)
        if xl != yl:
            if self.table[xl] <= self.table[yl]:
                self.table[yl] = xl
                self.table[xl] -= 1
            else:
                self.table[xl] = yl
                self.table[yl] -= 1
n, m = map(int, input().split())
p = list(map(int, input().split()))
edges = [tuple(map(int, input().split())) for _ in range(m)]
place = Unionfind(n)
d = {}
for x, y in edges:
    place.union(x-1, y-1)
loot = [0] * n
for i in range(n):
    loot[i] = place.find(i)
    if loot[i] not in d:
        d[loot[i]] = {p[i]-1}
    else:
        d[loot[i]].add(p[i]-1)
counter = 0
for i in range(n):
    if i in d[loot[i]]:
        counter += 1
print(counter)
### BUGGY CODE ###

N = int(input())

A = []

for i in range(0, N):
    A.append(int(input()))

for i in range(0, N):
    print(max(A[0:i] + A[i+1:N]))

### FIXED CODE ###

N = int(input())

A = []

for i in range(0, N):
    A.append(int(input()))

max1 = sorted(A)[-1]
max2 = sorted(A)[-2]


for i in A:
    if i == max1:
        print(max2)
    else:
        print(max1)
### BUGGY CODE ###

s=input()
a=input()
a=a.split()


c=1
for x in a:
  c=c*int(x)
  
if c > 10**18:
  print("-1")
else:  
  print(c) 


### FIXED CODE ###

a=int(input())
A=list(map(int,input().split()))
ans=1
if A.count(0)==0:
    for x in A:
      ans*=x
      if ans>10**18:
        break


    if ans>10**18:
      print(-1)
    else:
      print(ans)
else:
  print(0)
### BUGGY CODE ###

while 1:
        n = map(int,raw_input().split())
        if n[0] == n[1] == 0:
                break
        m, o = [1 for x in range(n[0])], 0

        for x in range(1,n[1]+1):
                a = raw_input()
                print o
                if sum(m) == 1:
                        pass
                elif x % 15 == 0:
                        if a != "FizzBuzz":
                                m[o] = 0
                elif x % 3 == 0:
                        if a != "Fizz":
                                m[o] = 0
                elif x % 5 == 0:
                        if a != "Buzz":
                                m[o] = 0
                else:
                        if a != str(x):
                                m[o] = 0
                while 1:
                        o += 1
                        if o == len(m):
                                o = -1
                        elif m[o] == 1:
                                break

        for x in range(n[0]):
                if m[x] == 1:
                        print x+1,
        print ""

### FIXED CODE ###

while 1:
        n = map(int,raw_input().split())
        if n[0] == n[1] == 0:
                break
        m, o = [1 for x in range(n[0])], 0

        for x in range(1,n[1]+1):
                a = raw_input()
                if sum(m) == 1:
                        pass
                elif x % 15 == 0:
                        if a != "FizzBuzz":
                                m[o] = 0
                elif x % 3 == 0:
                        if a != "Fizz":
                                m[o] = 0
                elif x % 5 == 0:
                        if a != "Buzz":
                                m[o] = 0
                else:
                        if a != str(x):
                                m[o] = 0
                while 1:
                        o += 1
                        if sum(m) == 1:
                                break
                        elif o == len(m):
                                o = -1
                        elif m[o] == 1:
                                break

        OutPut = ""
        for x in range(n[0]):
                if m[x] == 1:
                        OutPut += str(x+1) + " "
        print OutPut[:-1]
### BUGGY CODE ###

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

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

now = 1

d = []

while True:
    if A[now-1] in d:
        i = d.index(A[now-1])
        check = d[i:]
        break
    d.append(A[now-1])
    now = A[now-1]

if K <= len(d):
    print(d[K-1])
else:
    K -= (len(d)-len(check))
    K = K % len(check)
    print(check[K-1])



### FIXED CODE ###

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

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

now = 1

d = []
set_d = set()

while True:
    if A[now-1] in set_d:
        i = d.index(A[now-1])
        check = d[i:]
        break
    now = A[now-1]
    d.append(now)
    set_d.add(now)

    if len(set_d) >= K:
        break

if K <= len(set_d):
    print(d[K-1])
else:
    K -= (len(set_d)-len(check))
    K = K % len(check)
    print(check[K-1])
### BUGGY CODE ###

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

mod = 10**9+7
ans = 0

for k in range(60):
    x, y = 0, 0
    for a in A:
        x += 1 & a>>k
    tmp = x*(n-x)%mod
    tmp *= pow(2, k, mod)
    ans += tmp%mod
print(ans%mod)

### FIXED CODE ###

def main():
    n = int(input())
    A = list(map(int, input().split()))

    mod = 10**9+7
    ans = 0

    for k in range(60):
        x, y = 0, 0
        for a in A:
            x += 1 & a>>k
        tmp = x*(n-x)%mod
        tmp *= pow(2, k, mod)
        ans += tmp
        ans %= mod
    print(ans)


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

def main():
  mod=998244353
  n,m,k=map(int,input().split())
  def ncr_mod(n,r,mod):
    a,b=1,1
    for i in range(r):
      a*=n-i
      a%=mod
      b*=i+1
      b%=mod
    return (a*pow(b,mod-2,mod))%mod
  ans=m*pow(m-1,n-1,mod)
  ans%=mod
  for i in range(1,k+1):
    ans+=m*pow(m-1,n-1-i,mod)*ncr_mod(n-1,i,mod)
    ans%=mod
  print(ans)
    
if __name__=='__main__':
  main()


### FIXED CODE ###

def main():
  mod=998244353
  n,m,k=map(int,input().split())
  def cmb(n, r, mod):
      if ( r<0 or r>n ):
          return 0
      r = min(r, n-r)
      return g1[n] * g2[r] * g2[n-r] % mod
  g1 = [1, 1] 
  g2 = [1, 1] 
  inverse = [0, 1]
  for i in range( 2, n + 1 ):
      g1.append( ( g1[-1] * i ) % mod )
      inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
      g2.append( (g2[-1] * inverse[-1]) % mod )

  ans=m*pow(m-1,n-1,mod)
  ans%=mod
  for i in range(1,k+1):
    ans+=(m*pow(m-1,n-1-i,mod))%mod*cmb(n-1,i,mod)
    ans%=mod
  print(ans)
  
if __name__=='__main__':
  main()
### BUGGY CODE ###

import math

def routeCombCount(distance):
  comb_count = 1
  max_skippable_count = distance // 2

  if max_skippable_count == 0:
    return 1

  for skippable_count in range(1, max_skippable_count + 1):
    step_count = distance - skippable_count
    comb_count += combinations_count(step_count, skippable_count)

  return comb_count

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

count = 1
aim_stage = N
now_stage = 0
before_broken = -1
for i in range(M):
  broken = int(input())
  if broken == before_broken + 1:
    count = 0
    break

  aim_stage = broken - 1
  distance = aim_stage - now_stage

  count *= routeCombCount(distance)

  before_broken = broken
  now_stage = broken + 1

distance = N - now_stage
count *= routeCombCount(distance)

print(count % 1000000007)

### FIXED CODE ###

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

halls = {}
for i in range(M):
    index = int(input())
    halls[index] = True

dp = [1] * (N + 1)

for i in range(1, N + 1):
    if i in halls:
        dp[i] = 0
        continue
    if i == 1:
        continue
    dp[i] = dp[max(0, i - 1)] + dp[max(0, i - 2)]
    
print(dp[N] % 1000000007)
### BUGGY CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))
A = [(p + 1) / 2 for p in P]
ans = 0
for i in range(K - 1, N):
    a = 0
    for j in range(K):
        a += A[i - j]
    if a > ans:
        ans = a
print(ans)


### FIXED CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))
A = [(p + 1) / 2 for p in P]
B = [0 for i in range(N)]
B[0] = A[0]
for i in range(1, N):
    B[i] = B[i - 1] + A[i]
ans = 0
for i in range(K - 1, N):
    if i == K - 1:
        a = B[i]
    else:
        a = B[i] - B[i - K]
    if ans < a:
        ans = a
print(ans)
### BUGGY CODE ###

n=int(input())
lista = [int(i) for i in input().split()]
listb=[1]*n
for i in range(n):
    listb[lista[i]-1]=i+1

ans=""
for i in range(n):
    ans+=str(listb[i])+" "
print(ans)

### FIXED CODE ###

n=int(input())
lista = [int(i) for i in input().split()]
listb=[1]*n
for i in range(n):
    listb[lista[i]-1]=i+1


for i in range(n):

    print(str(listb[i])+" ", end="")
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**8)

n, m = map(int, input().split())
depth = [0 for _ in range(n)]
chil = [[] for _ in range(n)]
rank = [0 for _ in range(n)]
parent = [-1 for _ in range(n)]
for _ in range(n+m-1):
	a, b = map(int, input().split())
	chil[a-1].append(b-1)
	rank[b-1] += 1

#print(chil)
for i in range(n):
	if rank[i] == 0:
		par = i
		break

parent[par] = -1

def dfs(x, d):
	for c in chil[x]:
		if depth[c] == -1:
			depth[c] = d+1
			parent[c] = x
			dfs(c, d+1)
		elif depth[c] < d+1:
			depth[c] = d+1
			parent[c] = x
			dfs(c, d+1)

	return

dfs(par, 0)

for p in parent:
	print(p+1)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
#from collections import deque

n, m = map(int, input().split())
depth = [0 for _ in range(n)]
chil = [[] for _ in range(n)]
rank = [0 for _ in range(n)]
parent = [-1 for _ in range(n)]
#visited = [False for _ in range(n)]
for _ in range(n+m-1):
	a, b = map(int, input().split())
	chil[a-1].append(b-1)
	rank[b-1] += 1

#print(chil)
for i in range(n):
	if rank[i] == 0:
		par = i
		break

parent[par] = -1

#def bfs(x):
#	que = deque([[x, 0]])
#	while que:
#		l = que.pop()
#		y, d = l[0], l[1]
#		print(y, d)
#		if d < depth[y]:
#			continue
#		for c in chil[y]:
#			if depth[c] == -1:
#				depth[c] = d+1
#				parent[c] = y
#				que.appendleft([c, d+1])
#			elif depth[c] < d+1:
#				depth[c] = d+1
#				parent[c] = y
#				que.appendleft([c, d+1])
#
#	return

#bfs(par)

def dfs(x):
	true_chil = []
	for c in chil[x]:
		if rank[c] == 1:
			true_chil.append(c)
		else:
			rank[c] -= 1
	for t in true_chil:
		parent[t] = x
		dfs(t)

	return

dfs(par)

for p in parent:
	print(p+1)
### BUGGY CODE ###

n,k=map(int,input().split())
p=list(map(int,input().split()))
a=0
b=0

for i in range(n-k+1):
    if sum(p[i:i+k]) >= a:
        a=sum(p[i:i+k]) 
        b=i

print((k+a)/2)

### FIXED CODE ###

n,k=map(int,input().split())
p=list(map(int,input().split()))
a=0
for i in range(n-k+1):
    if i==0:
        xe=sum(p[0:k])
    else:
        xe=xe-p[i-1]+p[i+k-1]
    a=max(a,xe)
print((k+a)/2)
### BUGGY CODE ###

R, G, B, N = map(int, input().split())
ans = 0
for r in range(N + 1):
    for g in range(N + 1):
        b = (N - r * R - g * G) / B
        if int(b) == b and b >= 0:
            ans += 1

print(ans)


### FIXED CODE ###

R, G, B, N = map(int, input().split())
ans = 0
for r in range(N + 1):
    for g in range(N + 1):
        b = (N - r * R - g * G) / B
        if int(b) == b and b >= 0:
            ans += 1

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

import math

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

max_value = 0
n = min(N, B-1)

for i in range(1, n+1):
    tmp =  math.floor(A*i/B) - A* math.floor(i/B)
    if tmp >= max_value:
        max_value = tmp

    
print(max_value)

### FIXED CODE ###

import math

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

max_value = 0
n = min(N, B-1)

max_value =  math.floor(A*n/B) - A* math.floor(n/B)


    
print(max_value)
### BUGGY CODE ###

A, B, N = map(int, input().split())
ans = []

for i in range(1, N+1):
    ans.append((A * i // B) - A * (i // B))

print(max(ans))

### FIXED CODE ###

import math

A, B, N = map(int, input().split())
x = min(B-1, N)
ans = math.floor(A * (x % B) / B)
print(ans)
### BUGGY CODE ###


N=int(input())
Data=list(map(int,input().split()))
mindata=min(Data)-1
maxdata=max(Data)+1
ans=0
for i in range(mindata,maxdata+1):
    cnt=0
    for j in range(N):
        if abs(Data[j]-i)<=1:cnt+=1
    if ans<cnt:
        ans=cnt
print(ans)


### FIXED CODE ###

from collections import Counter

N=int(input())

counter=Counter(list(map(int,input().split())))
res=0

for i in counter:
    cnt=counter[i-1]+counter[i]+counter[i+1]
    if res<cnt:res=cnt
print(res)
### BUGGY CODE ###

from operator import itemgetter
import sys


class BIT:
    def __init__(self, size: int):
        self.size = size + 1
        self.array = [0] * self.size

    def add(self, i, x):
        if not i > 0:
            return
        while i < self.size:
            self.array[i] += x
            i += i & -i

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.array[i]
            i -= i & -i
        return s


def read():
    return sys.stdin.readline().rstrip()


def main():
    n, q = map(int, read().split())
    c = [int(i) for i in read().split()]
    queries = [() for _ in range(q)]
    for i in range(q):
        l, r = map(int, read().split())
        queries[i] = (i, l, r)
    queries.sort(key=itemgetter(2))
    last = [0] * n
    bit = BIT(n)
    ans = [-1] * q
    cr = 0
    for i, l, r in queries:
        for ri in range(cr, r):
            ci = c[ri] - 1
            bit.add(last[ci], -1)
            last[ci] = ri + 1
            bit.add(last[ci], 1)
            cr = ri
        ans[i] = bit.sum(r) - bit.sum(l - 1)
    print(*ans, sep="\n")


if __name__ == '__main__':
    main()


### FIXED CODE ###

from operator import itemgetter
import sys


class BIT:
    def __init__(self, size: int):
        self.size = size + 1
        self.array = [0] * self.size

    def add(self, i, x):
        if not i > 0:
            return
        while i < self.size:
            self.array[i] += x
            i += i & -i

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.array[i]
            i -= i & -i
        return s


def read():
    return sys.stdin.readline().rstrip()


def main():
    n, q = map(int, read().split())
    c = [int(i) for i in read().split()]
    queries = [() for _ in range(q)]
    for i in range(q):
        l, r = map(int, read().split())
        queries[i] = (i, l, r)
    queries.sort(key=itemgetter(2))
    last = [0] * n
    bit = BIT(n)
    ans = [-1] * q
    cr = 0
    for i, l, r in queries:
        for ri in range(cr, r):
            ci = c[ri] - 1
            bit.add(last[ci], -1)
            last[ci] = ri + 1
            bit.add(last[ci], 1)
            cr = ri
        ans[i] = bit.sum(r) - bit.sum(l - 1)
    print(*ans, sep="\n")


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

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini :
            mini = A[i+L-1]
        elif A[i-1] == mini :
            mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini :
            mini = A[i]
        elif A[i+L] == mini:
            mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
ascend(0,N//2)
descend(N//2,N-L+1)

for i in ans[:-1] : print(i, end=" ")
print(ans[-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

if __name__ == '__main__':
    store = list()
    for i in range(int(input())):
        parts = input().split()
        cmd = parts[0]
        if cmd == 'insert':
            store.insert(0, int(parts[1]))
        elif cmd == 'delete':
            num = int(parts[1])
            if num in store:
                store.remove(num)
        elif cmd == 'deleteFirst':
            store.remove(store[0])
        elif cmd =='deleteLast':
            store = store[:-1]
    print(' '.join(map(str, store)))


### FIXED CODE ###

class Node(object):
    def __init__(self, value, next=None, prev=None):
        self.value = value
        self.next = next
        self.prev = prev

class LinkedList(object):

    def __init__(self):
        self.dummy = Node(None)
        self.dummy.next = self.dummy
        self.dummy.prev = self.dummy

    def insert(self, x):
        node = Node(x, self.dummy.next, self.dummy)

        self.dummy.next.prev = node
        self.dummy.next = node
    
    def delete(self, x):
        node = self.dummy.next
        while node != self.dummy:
            if node.value == x:
                self.__remove_node(node)
                break
            else:
                node = node.next
    
    def deleteFirst(self):
        self.__remove_node(self.dummy.next)

    def deleteLast(self):
        self.__remove_node(self.dummy.prev)

    def __remove_node(self, node):
        if node != self.dummy:
            node.prev.next = node.next
            node.next.prev = node.prev

    def items(self):
        ret = []
        node = self.dummy.next
        while node != self.dummy:
            ret.append(node.value)
            node = node.next
        return ret

def main():
    from sys import stdin
    store = LinkedList()
    for i in range(int(input())):
        parts = stdin.readline().strip().split()
        cmd = parts[0]
        if cmd == 'insert':
            store.insert(parts[1])
        elif cmd == 'delete':
            store.delete(parts[1])
        elif cmd == 'deleteFirst':
            store.deleteFirst()
        elif cmd =='deleteLast':
            store.deleteLast()

    print(' '.join(store.items()))

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

n=int(input())
a=list(map(int,input().split()))
s=0
for j in range(60):
    cnt1=0
    cnt0=0
    for i in range(n):
      if (a[i]>>j)&1:
        cnt1+=1
      else:
        cnt0+=1
    s+=(cnt1*cnt0*2**j)%(10**9+7)
print(s%(10**9+7))


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=0
mod=10**9+7
for j in range(60):
    cnt1=sum([1 for i in a if i>>j&1])
    cnt0=n-cnt1
    ans+=(cnt1*cnt0*2**j)
print(ans%(10**9+7))
### BUGGY CODE ###

# coding: utf-8
# Your code here!
S = input()
Q = int(input())
Qlist = [list(input().split()) for _ in range(Q)]

#print(S)
i=0
while i<Q:
    if Qlist[i][0]=="1":
        S=S[::-1]
    else:
        check=Qlist[i][2]
        if Qlist[i][1]=="1":
            S=check+S
        else:
            S=S+check
    i+=1

print(S)
    
    





### FIXED CODE ###

S = input()
Q = int(input())
Qlist = [list(input().split()) for _ in range(Q)]
toplist=[]
backlist=[]
Flag=1

i=0
while i<Q:
    if Qlist[i][0]=="1":
        Flag*=-1
    else:
        #check=Qlist[i][2]
        if Qlist[i][1]=="1" and Flag==-1:
            backlist.append(Qlist[i][2])
        elif Qlist[i][1]=="1" and Flag==1:
            toplist.append(Qlist[i][2])
        elif Qlist[i][1]=="2" and Flag==-1:
            toplist.append(Qlist[i][2])
        elif Qlist[i][1]=="2" and Flag==1:
            backlist.append(Qlist[i][2])
    i+=1
if Flag==1:
    #print(toplist)
    #print(S)
    #print(backlist)
    print("".join(toplist[::-1])+S+"".join(backlist))
else:
    #print(backlist[::-1])
    #print(S)
    #print(toplist[::-1])
    print("".join(backlist[::-1])+S[::-1]+"".join(toplist))
### BUGGY CODE ###

import fractions
from functools import reduce
def gcd(i):
    return reduce(fractions.gcd, i)
N = int(input())
A = list(map(int, input().split()))
tmp = 0
if gcd(A) == max(A):
    print(gcd(A))
    exit()
else:
    for i in range(N):
        if i == 0 :
            tmp=max(tmp,gcd(A[1:]))
        elif i == N-1:
            tmp=max(tmp,gcd(A[:N-1]))
        else:
            tmp=max(tmp,gcd(A[:i]+A[i+1:]))
print(tmp)

### FIXED CODE ###

import fractions
from functools import reduce
def gcd(*i):
    return reduce(fractions.gcd, i)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    L=[0]
    R=[0]
    for i in range(N):
        L.append(gcd(L[i],A[i]))
        R.append(gcd(R[i],A[-(i+1)]))
    R=R[::-1]
    ans=[]
    for i in range(N):
        ans.append(gcd(L[i],R[i+1]))
    print(max(ans))
if __name__ == "__main__":
    main()
### BUGGY CODE ###

s = input().split()

n = int(s[0])
m = int(s[1])

#ll = [set() for j in range(n + 1)]
sl = set()
ld = {}

s1 = {1}
s2 = set()


for i in range(m):
    t = input().split()
    sl.add(int(t[0]))
    sl.add(int(t[1]))
    #ll[int(t[0])].add(int(t[1]))
    #ll[int(t[1])].add(int(t[0]))
    if int(t[0]) in ld:
        ld[int(t[0])].add(int(t[1]))
    else:
        ld[int(t[0])] = {int(t[1])}
    if int(t[1]) in ld:
        ld[int(t[1])].add(int(t[0]))
    else:
        ld[int(t[1])] = {int(t[0])}


if sum(sl) < int(((n + 1) * n ) / 2):
    print("No")
else:
    count = 0
    mydict = {}
    out = 0

    while count < n:
        s2.clear()
        for i in ld:
            if len(s1 & ld[i]) != 0:
                s3 = list(s1 & ld[i])
                mydict.setdefault(i,s3[0])
                s2.add(i)
                count += 1
        for i in s2:
            del ld[i]
        s1 = s2.copy()

    print("Yes")
    for i in range(2,n+1):
        print(mydict[i])


### FIXED CODE ###

import collections

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

coriddorList = [set() for i in range(n+1)]
deepList = [-1 for i in range(n+1)]


for i in range(m):
    a,b = list(map(int,input().split()))
    coriddorList[a].add(b)
    coriddorList[b].add(a)

checkList = [0] * (n + 1)
ansList = [0] * (n + 1)
checkList[1] = 1
q = collections.deque()
q.appendleft(1)

while len(q) > 0:
    value = q.pop()
    for k in coriddorList[value]:
        if checkList[k] == 0:
            checkList[k] = 1
            ansList[k] = value
            q.appendleft(k)

print("Yes")
for i in range(2,n+1):
    print(ansList[i])
### BUGGY CODE ###

n =int(input())
A=[]
for I in range(n):
  moji=list(input())
  moji.sort()
  moji=''.join(moji)
  A.append(moji)
N=0
for i in range(n):
  a=A[i]
  for s in range(i+1,n,1):
    b=A[s]
    if a==b:
      N+=1
print(N)

### FIXED CODE ###

n =int(input())
A=[]
for I in range(n):
  moji=list(input())
  moji.sort()
  moji=''.join(moji)
  A.append(moji)
A.sort()
N=0
SUM=0
i=0
while True:
  if i==n-1:
    SUM=SUM+int(0.5*N*(N+1))
    break
  a=A[i]
  for s in range(i+1,n,1):
    b=A[s]
    if a==b:
      N+=1
      i+=1
    else:
      SUM=SUM+int(0.5*N*(N+1))
      N=0
      i=s
      break
print(SUM)