Harryxun/stf_run huggingface dataset:
class dice:
    def __init__(self,label):
        self.d = label
    def roll(self,op):
        d = self.d
        if   op=='N': self.d = [d[1],d[5],d[2],d[3],d[0],d[4]]
        elif op=='E': self.d = [d[3],d[1],d[0],d[5],d[4],d[2]]
        elif op=='W': self.d = [d[2],d[1],d[5],d[0],d[4],d[3]]
        elif op=='S': self.d = [d[4],d[0],d[2],d[3],d[5],d[1]]
    def print(self):
        print(self.d[0])
    def print_r_side(self,t,f):
        d = self.d
        if   (t,f)==(d[0],d[1]): print(d[2])
        elif (t,f)==(d[0],d[2]): print(d[4])
        elif (t,f)==(d[0],d[3]): print(d[1])
        elif (t,f)==(d[0],d[4]): print(d[3])
        elif (t,f)==(d[1],d[0]): print(d[3])
        elif (t,f)==(d[1],d[2]): print(d[0])
        elif (t,f)==(d[1],d[3]): print(d[5])
        elif (t,f)==(d[1],d[5]): print(d[2])
        elif (t,f)==(d[2],d[0]): print(d[1])
        elif (t,f)==(d[2],d[1]): print(d[5])
        elif (t,f)==(d[2],d[4]): print(d[0])
        elif (t,f)==(d[2],d[5]): print(d[4])
        elif (t,f)==(d[3],d[0]): print(d[4])
        elif (t,f)==(d[3],d[1]): print(d[0])
        elif (t,f)==(d[3],d[4]): print(d[5])
        elif (t,f)==(d[3],d[5]): print(d[1])
        elif (t,f)==(d[4],d[0]): print(d[2])
        elif (t,f)==(d[4],d[2]): print(d[5])
        elif (t,f)==(d[4],d[3]): print(d[0])
        elif (t,f)==(d[4],d[5]): print(d[3])
        elif (t,f)==(d[5],d[1]): print(d[3])
        elif (t,f)==(d[5],d[2]): print(d[1])
        elif (t,f)==(d[5],d[3]): print(d[4])
        elif (t,f)==(d[5],d[4]): print(d[2])

label = list(map(int,input().split()))
q = int(input())
d0 = dice(label)
for _ in range(q):
    t,f = list(map(int,input().split()))
    d0.print_r_side(t,f)

### FIXED CODE ###

class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
    def print_top(self): print(self.top)
 
label = list(map(int,input().split()))
op_list = list(input())
d = dice(label)
for op in op_list:
    d.roll(op)
d.print_top()
n, k = map( int, input().split())
hate = set( input().split())

usable = sorted( list( {str(i) for i in range(10)} - hate))

l = len(str(n))

def check(l):
    num = []
    if l == 1:
        for i in usable:
            num.append(i)
    if l == 2:
        for ii in usable:
            for i in usable:
                num.append(int( str(ii) + str(i)))
    elif l == 3:
        for iii in usable:
            for ii in usable:
                for i in usable:
                    num.append(int( str(iii) + str(ii) + str(i)))
    elif l == 4:
        for iv in usable:
            for iii in usable:
                for ii in usable:
                    for i in usable:
                        num.append(int( str(iv) + str(iii) + str(ii) + str(i)))
    else:
        for v in usable:
            for iv in usable:
                for iii in usable:
                    for ii in usable:
                        for i in usable:
                            num.append(int( str(v) + str(iv) + str(iii) + str(ii) + str(i)))
    return num

truf = False
num = check(l)
for i in num:
    if n <= i:
        print(i)
        truf = True
        break
if not truf:
    num = check(l+1)
    for i in num:
        if n <= i:
            print(i)

### FIXED CODE ###

n, k = map( int, input().split())
hate = set( input().split())

usable = sorted( list( {str(i) for i in range(10)} - hate))

l = len(str(n))

def check(l):
    num = []
    if l == 1:
        for i in usable:
            num.append(int(i))
    elif l == 2:
        for ii in usable:
            for i in usable:
                num.append(int( ii + i))
    elif l == 3:
        for iii in usable:
            for ii in usable:
                for i in usable:
                    num.append(int( iii + ii + i))
    elif l == 4:
        for iv in usable:
            for iii in usable:
                for ii in usable:
                    for i in usable:
                        num.append(int( iv + iii + ii + i))
    else:
        for v in usable:
            for iv in usable:
                for iii in usable:
                    for ii in usable:
                        for i in usable:
                            num.append(int( str(v) + str(iv) + str(iii) + str(ii) + str(i)))
    return num

truf = False
num = check(l)
for i in num:
    if n <= i:
        print(i)
        truf = True
        break
if not truf:
    num = check(l+1)
    for i in num:
        if n <= i:
            print(i)
            break
list = []
n = input()
for i in range(n):
    a,b=input().split()
    list.append((int(a), int(b)))
for i in n-2:
  if list[i][0] == list[i][1] and list[i+1][0] == list[i+1][1] and list[i+2][0] == list[i+2][1]:
	print("Yes")
  return 0

else :print("No")

### FIXED CODE ###

ans = "No"
count = 0
n = int(input())
for i in range(n):
  a,b=map(int,input().split())
  if a == b:
    count += 1
    if count >= 3:
        ans ="Yes"
  else:
    count = 0

print(ans)
H, W = map(int, input().split())
state = [list(map(str, input().split())) for _ in range(h)]

A = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for h in range(H):
  for w in range(W):
    if state[h][w] == 'snuke':
      ans = A[w] + str(h+1)
print(ans)

### FIXED CODE ###

H, W = map(int, input().split())
state = [list(map(str, input().split())) for _ in range(H)]

A = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for h in range(H):
  for w in range(W):
    if state[h][w] == 'snuke':
      ans = A[w] + str(h+1)
print(ans)
N = int(input())
W = list(map(int, input().split()))
 
ans = 10000
for i in range(N):
    mi = abs(sum(W[0:i]) - sum(W[i:])
    if mi < ans:
        ans = mi
print(ans)

### FIXED CODE ###

n = int(input())
w = list(map(int, input().split()))
 
min_diff = 1000
for i in range(n):
	diff = abs(sum(w[0:i]) - sum(w[i:]))
	if diff < min_diff:
		min_diff = diff
print(min_diff)
n = int(input())
a =0
b =0
for i in range(n):
    nums = [int(num) for num in input().split]
    aa = nums[0]
    bb = nums[1]
    if aa > a:
        a = aa
        b = bb
print(a + b)
    

### FIXED CODE ###

n = int(input())
a =0
b =0
for i in range(n):
    nums = [int(num) for num in input().split()]
    aa = nums[0]
    bb = nums[1]
    if aa > a:
        a = aa
        b = bb
print(a + b)
A = int(input())
B = int(input())
C = int(input())
K = int(input())
S = A + B + C

if A >=K or A + B >=K:
  print(A)
else :
  print(A-1*(K-A-B))

### FIXED CODE ###

A,B,C,K = map(int,input().split())

if K >A+B:
  print(A-1*(K-A-B))
elif A > K :
  print(K)
else :
  print(A)
n = int(input())

c = [0]*(n+1)
c[0],c[1] = map(int,input().split())

for i in range(2,n+1):
    c[i] = int(input().split()[1])

dp = [[sys.maxsize]*(n+1) for i in range(n+1)]

for i in range(1,n+1):
    dp[i][i] = 0

for l in range(2,n+1) :#length of chain j-i+1
    for i in range(1,n-l+2):
        j = i +l - 1:
        for k in range(i,j):
            dp[i][j] = min(dp[i][j],dp[i][k]+ dp[k+1][j]+c[i-1]*[k]*c[j])


print(dp[1][n])

### FIXED CODE ###

import sys

n = int(input())

c = [0]*(n+1)
c[0],c[1] = map(int,input().split())

for i in range(2,n+1):
    c[i] = int(input().split()[1])

dp = [[sys.maxsize]*(n+1) for i in range(n+1)]

for i in range(1,n+1):
    dp[i][i] = 0

for l in range(2,n+1) :#length of chain j-i+1
    for i in range(1,n-l+2):
        j = i +l - 1
        for k in range(i,j):
            dp[i][j] = min(dp[i][j],dp[i][k]+ dp[k+1][j]+c[i-1]*c[k]*c[j])


print(dp[1][n])
N = int(input())
P = (int(i) for i in input().split())
Q = (int(i) for i in input().split())

seq = tuple(range(N))
import itertools
p_list = list(itertools.permutations(seq))
for i,p in enumerate(p_list):
  if p_list == P:
    p_idx = i
  elif p_list == Q:
    q_idx = i
print(abs(p_idx-q_idx))

### FIXED CODE ###

N = int(input())
P = tuple(int(i) for i in input().split())
Q = tuple(int(i) for i in input().split())

seq = tuple(range(1,N+1))
import itertools
p_list = list(itertools.permutations(seq))
for i,p in enumerate(p_list):
  if p == P:
    p_idx = i
  if p == Q:
    q_idx = i
print(abs(p_idx-q_idx))
ss=input()
ans=0
 for i in range(2**(len(ss)-1)):
    temp=ss[0]
    for j in range(len(ss)-1):
        if i&(1<<j)!=0:
            temp+="+"
        temp+=ss[j+1]
    ans+=eval(temp)
print(ans)

### FIXED CODE ###

S = input()
ans = 0
 
for i in range(2**(len(S)-1)):
    temp = S[0]
    for j in range(len(S)-1):
        if i & (1<<j) != 0:
            temp += "+"
        temp += S[j+1]
    ans += eval(temp)
print(ans)
n = int(input())
A = list(map(int,input().split()))
A.sort()
ans = []

# 全て正
if min(A)>0:
    print(sum(A)-2*A[0])
    for i in range(n):
        if i==0:
            x = A[i]
        elif i==n-1:
            print(A[i], x)
        else:
            print(x, A[i])
            x -= A[i]

# 全て負
elif max(A)<0:
    A = A[::-1]
    print(sum(A)*(-1) + 2*A[0])
    for i in range(n):
        if i==0:
            x = A[i]
        elif i==n-1:
            print(A[i], x)
        else:
            print(x, A[i])
            x -= A[i]

# 正負
else:
    m,p = [], []
    for a in A:
        if a<0:
            m.append(a)
        else:
            p.append(a)
    print(sum(p)-sum(m))
    m.sort()
    p.sort()
    x = m[0]
    for i in range(len(p)-1):
        print(x, p[i])
        x -= p[i]
    else:
        print(p[-1], x)
        x = p[-1] - x
        
    for j in range(1, len(m)):
        print(x, m[j])
        x -= m[j]

### FIXED CODE ###

n = int(input())
A = list(map(int,input().split()))
A.sort()
ans = []

# 全て正
if min(A)>=0:
    print(sum(A)-2*A[0])
    for i in range(n):
        if i==0:
            x = A[i]
        elif i==n-1:
            print(A[i], x)
        else:
            print(x, A[i])
            x -= A[i]

# 全て負
elif max(A)<=0:
    A = A[::-1]
    print(sum(A)*(-1)+2*A[0])
    for i in range(n):
        if i==0:
            x = A[i]
        else:
            print(x, A[i])
            x -= A[i]

# 正負
else:
    m,p = [], []
    for a in A:
        if a<0:
            m.append(a)
        else:
            p.append(a)
    print(sum(p)-sum(m))
    m.sort()
    p.sort()
    x = m[0]
    for i in range(len(p)-1):
        print(x, p[i])
        x -= p[i]
    else:
        print(p[-1], x)
        x = p[-1] - x
        
    for j in range(1, len(m)):
        print(x, m[j])
        x -= m[j]
import numpy as np
l,r=map(int,input().split())
s=np.array(range(l,r+1))
ans=[2018]
for i in range(r-l):
    for j in range(i+1,r-l+1):
        ans=min((s[i]%2019)*(s[j]%2019),ans)
        if ans==0:
            break
print(ans)

### FIXED CODE ###

l,r=[int(i) for i in input().split()]
ans=2018
for i in range(l,r):
    for j in range(i+1,r+1):
        ans=min(i*j%2019,ans)
        if ans==0:
            print(ans)
            exit()
print(ans)
N,M,K= list(map(int, input().split()))
mod = 998244353

def cmbinit(n):
    fac = [0]*n
    finv = [0]*n
    inv = [0]*n
    fac[0]=fac[1] = 1
    finv[0]=finv[1] = 1
    inv[1] = 1
    for i in range(2,n):
        fac[i] = fac[i-1]*i %mod
        inv[i] = mod - inv[mod%i] * (mod//i) %mod
        finv[i] = finv[i-1] * inv[i]%mod
    
    return fac,finv

def cmb(n,r,fac,finv):
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
        
    return fac[n] * (finv[r] * finv[n - r] % mod) %mod




ans = 0
fac,finv = cmbinit(N)
for k in range(K+1):
    ans += (M * pow(M-1, N-k-1, mod) * cmb(N-1,k,fac,finv))%mod


print(ans%mod)

### FIXED CODE ###

import sys
N,M,K= list(map(int, input().split()))
mod = 998244353

if N == 1:
    print(M)
    sys.exit()


def cmbinit(n):
    fac = [0]*n
    finv = [0]*n
    inv = [0]*n
    fac[0]=fac[1] = 1
    finv[0]=finv[1] = 1
    inv[1] = 1
    for i in range(2,n):
        fac[i] = fac[i-1]*i %mod
        inv[i] = mod - inv[mod%i] * (mod//i) %mod
        finv[i] = finv[i-1] * inv[i]%mod
    
    return fac,finv

def cmb(n,r,fac,finv):
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0

    return fac[n] * (finv[r] * finv[n - r] % mod) %mod




ans = 0
fac,finv = cmbinit(N)
for k in range(K+1):
    ans += (M * pow(M-1, N-k-1, mod) * cmb(N-1,k,fac,finv))%mod


print(ans%mod)
import math


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


n, m = [int(_) for _ in input().split()]
s = input()
t = input()
a = lcm(n, m)
s_a = a // n
t_a = a // m
p = lcm(s_a, t_a)
result = True
for i in range(a//p):
    if s[(i*p)//s_a] != t[(i*p)//t_a]:
        result = False
if result:
    print(a)
else:
    print(-1)


### FIXED CODE ###

import fractions


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


n, m = [int(_) for _ in input().split()]
s = input()
t = input()
a = lcm(n, m)
s_a = a // n
t_a = a // m
p = lcm(s_a, t_a)
result = True
for i in range(a//p):
    if s[(i*p)//s_a] != t[(i*p)//t_a]:
        result = False
if result:
    print(a)
else:
    print(-1)
n = input()
sum = 0
 
for i in range(0, n-1):
   x = input()
   m[i] = x
   sum = sum + m[i]
 
min = min(m[i] for i in range(0, n-1))
max = max(m[i] for i in range(0, n-1))
 
print '%d %d %d' %(min, max, sum)

### FIXED CODE ###

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

print '%d %d %d' %(min(m), max(m), sum(m))
import numpy as np
s = input()
cnt = 0
ss = []
nums = np.array([(i+1)*2019 for i in range(200000//2019) if not "0" in str((i+1)*2019)])
for start in range(len(s)):
  end = start + 3
  while(end+1<=len(s)):
    if int(s[start:end+1]) in nums:
      cnt += 1
    end += 1
print(cnt)

### FIXED CODE ###

s, w = [int(i) for i in input().split()]
if s <= w:
  print("unsafe")
else:
  print("safe")
def main():
    N = int(input())
    A = list(map(int, input().split()))
    AA = [(v, i) for i, v in enumerate(A)]
    AA.sort(reverse=True)
    dp = [[0] * (N+1) for _ in range(N+1)]
    for i, (a, b) in enumerate(AA, start=1):
        for x in range(i+1):
            y = i - x
            if y == 0:
                dp[x][y] = dp[x-1][y] + abs(b - x+1) * a
            elif x == 0:
                dp[x][y] = dp[x][y-1] + abs(N-y-b) * a
            else:
                dp[x][y] = max(dp[x-1][y] + abs(b - x + 1) * a, dp[x][y-1] + abs(N-y-b) * a)
    for i in range(N+1):
        r = max(r, dp[i][N-i])
    return r
print(main())


### FIXED CODE ###

def main():
    N = int(input())
    A = list(map(int, input().split()))
    AA = [(v, i) for i, v in enumerate(A)]
    AA.sort(reverse=True)
    dp = [[0] * (N+1) for _ in range(N+1)]
    for i, (a, b) in enumerate(AA, start=1):
        for x in range(i+1):
            y = i - x
            if y == 0:
                dp[x][y] = dp[x-1][y] + abs(b - x+1) * a
            elif x == 0:
                dp[x][y] = dp[x][y-1] + abs(N-y-b) * a
            else:
                dp[x][y] = max(dp[x-1][y] + abs(b - x + 1) * a, dp[x][y-1] + abs(N-y-b) * a)
    r = 0
    for i in range(N+1):
        r = max(r, dp[i][N-i])
    return r
print(main())
N = int(input())
A = list(map(int, input().split()))

def up(i,pre):
    if i == len(A) - 1:
        return abs(A[pre] - A[i])
    res1 = res2 = float("inf")
    res1 = up(i + 1,i)
    if i + 2 <=len(A) -1:
        res2 = up(i + 2,i)
    return min(abs(A[pre] - A[i]) + res1,abs(A[pre] - A[i]) + res2)

print(min(up(1,0),up(2,0)))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
dp = [0 for _ in range(len(A))]
dp[0] = 0 
for i in range(1,N):
    if i - 2>=0:
        dp[i] = min(dp[i-1] + abs(A[i] - A[i-1]),dp[i-2] + abs(A[i] - A[i-2]))
    else:
        dp[i] =dp[i-1] + abs(A[i] - A[i-1])

print(dp[len(A)-1])
a, b = map(int, input().split())
number = str(a * b)
index = number.find('.')
number = number[:index]
print(number)

### FIXED CODE ###

# coding: utf-8
# Your code here!
from decimal import Decimal
a, b = input().split()
a = Decimal(str(a))
b = Decimal(str(b))
c = str(a * b)
index = c.find('.')
print(c[:index])
A, B = map(int, raw_input().split())

divisor = []

for i in xrange(2, min(A,B)):
    if A % i == 0 and B % i == 0:
        divisor.append(i)
        A /= i
        B /= i
        while (A%i == 0) or (B%i == 0):
            A /= i
            B /= i
    
print len(divisor)+1

### FIXED CODE ###

N = int(raw_input())

P = 1.0*((N-1)/2 +1) / N
print "{:12.10f}".format(P)
N, M, C = map(int, input().split())
B = {}
A = {}

B.append(map(int, input().split())
for i in range(N):
	A.append(list(map(int, input().split())))


sum = 0
count = 0

for i in range(N):
	sum = 0
	for j in range(M):
		sum += A[i][j]
		sum += B[j]
	sum += C
	if sum > 0:
		count += 1

print(count)

### FIXED CODE ###

# ファイルをオープンする
#test_data = open("test.txt", "r")

# 行ごとにすべて読み込んでリストデータにする
#line = test_data.readline()


#N, M, C = map(int, line.split())
N, M, C = map(int, input().split())
B = []
A = []

#line = test_data.readline()


#B = [int(b) for b in line.split()]
B = [int(b) for b in input().split()]
for i in range(N):
	A.append(list(map(int, input().split())))
	#line = test_data.readline()
	#A.append(list(map(int, line.split())))

sum = 0
count = 0

for i in range(N):
	sum = 0
	for j in range(M):
		sum += A[i][j] * B[j]
	sum += C
	if sum > 0:
		count += 1

print(count)
import fractions

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

gcd_l = [0]
gcd_r = [0]

for i in range(n):
  gcd_l.append(fractions.gcd(gcd_l[i], l[i]))
  gcd_r.append(fractions.gcd(gcd_r[i], l[-(i+1)]))
gcd_r = gcd_r[::-1]
# print(gcd_l)
# print(gcd_r)

ans = [0]*n
for i in range(n):
  ans[i] = fractions.gcd(gcd_l[i], gcd_r[i+1])
print(maxx(ans))


  

### FIXED CODE ###

import fractions

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

gcd_l = [0]
gcd_r = [0]

for i in range(n):
  gcd_l.append(fractions.gcd(gcd_l[i], l[i]))
  gcd_r.append(fractions.gcd(gcd_r[i], l[-(i+1)]))
gcd_r = gcd_r[::-1]
# print(gcd_l)
# print(gcd_r)

ans = [0]*n
for i in range(n):
  ans[i] = fractions.gcd(gcd_l[i], gcd_r[i+1])
print(max(ans))
import sys


def solve(n, m, links, parents):
    if m % 2 == 1:
        print(-1)
        return

    fixed = [len(l) % 2 == 0 for l in links]

    def reverse_links(s, t):
        v = s
        while v != t:
            p = parents[v]
            links[p][v] ^= 1
            v = p

    tmp_trace = set()
    tmp_pair = -1
    for v in range(n):
        if fixed[v]:
            continue
        if tmp_pair == -1:
            u = v
            while u != -1:
                tmp_trace.add(u)
                u = parents[u]
            tmp_pair = v
        else:
            u = v
            while u != -1:
                if u in tmp_trace:
                    reverse_links(v, u)
                    reverse_links(tmp_pair, u)
                    break
                u = parents[u]
            else:
                raise AssertionError
            fixed[v] = fixed[tmp_pair] = True
            tmp_trace.clear()
            tmp_pair = -1

        # print(v, tmp_trace, tmp_pair)

    assert tmp_pair == -1

    ans = []
    for v in range(n):
        for u, d in links[v].items():
            if d == 0:
                ans.append('{} {}'.format(v + 1, u + 1))
            else:
                ans.append('{} {}'.format(u + 1, v + 1))
    print('\n'.join(ans))


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

first_links = []
for line in sys.stdin:
    a, b = map(int, line.split())
    a -= 1
    b -= 1
    if a > b:
        a, b = b, a
    first_links.append((a, b))
first_links.sort()

links = [{} for _ in range(n)]
parents = [-1] * n
for a, b in first_links:
    links[a][b] = 0
    if parents[b] == -1:
        parents[b] = a

# print(links)
# print(parents)

solve(n, m, links, parents)


### FIXED CODE ###

import sys
from collections import deque

sys.setrecursionlimit(10 ** 5)


def solve(n, m, links):
    if m % 2 == 1:
        print(-1)
        return

    tree = [set() for _ in range(n)]
    parents = [-1] * n
    q = deque([0])
    while q:
        v = q.popleft()
        for u in links[v]:
            if parents[u] == -1:
                tree[v].add(u)
                parents[u] = v
                q.append(u)
            links[u].remove(v)

    parities = [len(l) % 2 for l in links]

    # print(links)
    # print(tree)
    # print(parents)
    # print(parities)

    def dfs(v):
        b = parities[v]
        for u in tree[v]:
            c = dfs(u)
            b ^= c
        if b:
            p = parents[v]
            links[p].remove(v)
            links[v].add(p)
        return b

    dfs(0)

    ans = ['{} {}'.format(v + 1, u + 1) for v in range(n) for u in links[v]]
    print('\n'.join(ans))


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

links = [set() for _ in range(n)]
for line in sys.stdin:
    a, b = map(int, line.split())
    a -= 1
    b -= 1
    links[a].add(b)
    links[b].add(a)

solve(n, m, links)
print("Yes")
N, M = map(int, input().split())
path = [[] for _ in range(N)]
ind = [0 for _ in range(N)]
lis = []
for o in range(N):
    lis.append(o)
for i in range(M):
    A, B = map(int, input().split())
    path[A-1].append(B-1)
    path[B-1].append(A-1)
que = path[0]
for p in que:
    lis.discard(p)
for l in que:
    U = path[l]
    for m in U:
        if m in lis:
            ind[m] = l
            lis.discard(m)
    que += U
    if lis == {}:
        break
for z in range(1,N):
    ind[z] += 1
    print(ind[z])

### FIXED CODE ###

print("Yes")
N, M = map(int, input().split())
path = [[] for _ in range(N)]
ind = [0 for _ in range(N)]
lis = [0] + [1 for _ in range(N-1)]
for i in range(M):
    A, B = map(int, input().split())
    path[A-1].append(B-1)
    path[B-1].append(A-1)
que = path[0]
for p in que:
    lis[p] = 0
for l in que:
    U = path[l]
    for m in U:
        if lis[m] ==1:
            ind[m] = l
            lis[m] = 0
            que.append(m)
    if lis == {}:
        break
for z in range(1,N):
    ind[z] += 1
    print(ind[z])
H = int(input())
W = int(input())
N = int(input())

cnt = 0
while paint >= N:
	paint += max(H,W)
	cnt += 1
    
print(cnt)

### FIXED CODE ###

H = int(input())
W = int(input())
N = int(input())

cnt, paint = 0, 0
while paint < N:
    paint += max(H,W)
    cnt += 1
print(cnt)
s = input()

if s = 'Sunny':
    print('Cloudy')
elif s = 'Cloudy':
    print('Rainy')
else s = 'Rainy':
    print('Sunny')

### FIXED CODE ###

s = input()

if s == 'Sunny':
    print('Cloudy')
elif s == 'Cloudy':
    print('Rainy')
elif s == 'Rainy':
    print('Sunny')
K = int(input())
S = input()
SS = (int(len(S)))
if S <= 0:
  print(s)
else:
print(S[:SS-K])+print('.',K)

### FIXED CODE ###

K = int(input())
S = input()
SS = (int(len(S)))
if SS-K <= 0:
  print(S)
else:
  print((S[:K-SS])+('.'*3))
n=int(input())
#A=list(map(int,input().split()))
#b=list(map(int,input().split()))
#s=[input() for _ in range(n)]
ans=0
for i in range(1,n+1):
        if len(str(i))=1:
                ans+=1
print(ans)



### FIXED CODE ###

n=int(input())
#A=list(map(int,input().split()))
#b=list(map(int,input().split()))
#s=[input() for _ in range(n)]
ans=0
for i in range(1,n+1):
        if len(str(i))%2==1:
                ans+=1
print(ans)
N = int(input())
H = list(map(int,input().split()))
ans = 1
for i in range(1,N):
  for j in range(i+1):
    if H[i] =< H[j]:
      break
    if j == i+1:
      ans +=1

print(ans)


### FIXED CODE ###

N = int(input())
H = list(map(int,input().split()))
ans = 1
for i in range(1,N):
  for j in range(i):
    if H[i] < H[j]:
      break
    if j == i-1:
      ans +=1

print(ans)
import math
count = 0
n,d = map(int,input().split())
for i in range(n):
  x,y = map(int,input().split())
  if sqrt(x**2+y**2) >= d:
    count += 1
print(count)

### FIXED CODE ###

count = 0
x = 0
y = 0
n,d = map(int,input().split())
for i in range(n):
  x,y = map(int,input().split())
  if (x**2+y**2 )** 0.5 <= d:
    count += 1
print(count)