Harryxun/stf_run huggingface dataset:
class UnionFind:
    def __init__(self, length):
        self.parent_indexes = [-1]* length
        
    def union(self, i, j):
        if self.are_in_the_same_group(i, j):
            return
        # iが所属する集団のサイズ>=jが所属する集団のサイズにする
        if self.get_group_size(i) < self.get_group_size(j):
            i, j = j, i
                parent_of_i = self.find(i)
        self.parent_indexes[self.find(i)] = - self.get_group_size(i) - self.get_group_size(j)
        self.parent_indexes[self.find(j)] = self.find(i)
        
    # i番目の要素が所属する集団の親nodeのindexを返す
    # メモ化もする
    def find(self, i):
        if self.parent_indexes[i] < 0:
            return i
        parent_index = self.find(self.parent_indexes[i])
        self.parent_indexes[i] = parent_index
        return parent_index

    def get_group_size(self, i):
        return - self.parent_indexes[self.find(i)]
    
    def are_in_the_same_group(self, i, j):
        return self.find(i) == self.find(j)
    
    
n, q = list(map(lambda x: int(x), input().split()))
uf = UnionFind(n)
for _ in range(q):
    t, u, v = list(map(lambda x: int(x), input().split()))
#     print(uf.parent_indexes)
    if t == 0:
        uf.union(u, v)
        continue
    print('1') if uf.are_in_the_same_group(u, v) else print('0')

### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):
        return len(self.roots())
 
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
 
      
n, q = list(map(lambda x: int(x), input().split()))
uf = UnionFind(n)
for _ in range(q):
    t, u, v = list(map(lambda x: int(x), input().split()))
#     print(uf.parent_indexes)
    if t == 0:
        uf.union(u, v)
        continue
    print('1') if uf.same(u, v) else print('0')
N, M = map(int, input().split())
bs = [int(input()) for _ in range(M)]
bi = 0
pattern = [-1] * N

if bi < M and 1 == bs[bi]:
    pattern[0] = 0
    bi += 1
else:
    pattern[0] = 1

if bi < M and 2 == bs[bi]:
    pattern[1] = 0
    bi += 1
else:
    pattern[1] = 1 + pattern[0]

for i in range(2, N):
    if bi < M and (i + 1) == bs[bi]:
        pattern[i] = 0
        bi += 1
    else:
        pattern[i] = pattern[i -1] + pattern[i - 2]

print(pattern[-1] % 1000000007)


### FIXED CODE ###

N, M = map(int, input().split())
broken_step = [0] * (N + 1)
for _ in range(M):
    n = int(input())
    broken_step[n] = 1

dp = [1] * (N + 1)
dp[1] = 0 if broken_step[1] == 1 else dp[0]

for i in range(2, N + 1):
    if broken_step[i] == 1:
        dp[i] = 0
    else:
        dp[i] = dp[i -1] + dp[i - 2]

print(dp[-1] % 1000000007)
N, L = map(int, input().split())
 
#標準入力からリストの作成
list = []
for _ in range(N):
 i = input()
list.append(i)

#リストのソート
list_a = list.sorted()
 
#リストの結合
mojiretu = ''.join(list_a)
 
print(mojiretu)

### FIXED CODE ###

N, L = map(int, input().split())
 
#標準入力からリストの作成
list = []
for _ in range(N):
 i = str(input())
 list.append(i)

#リストのソート
list_a = sorted(list)
 
#リストの結合
mojiretu = ''.join(list_a)
 
print(mojiretu)
from math import sqrt

def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0:
        a, b = b, a%b
    return b

def divisor(a):
    lim = int(sqrt(a))
    divset = set()
    for i in range(1, lim + 1):
        if a % i == 0:
            divset |= {i, a//i}
    return divset

def is_prime(a):
    lim = int(sqrt(a))
    for i in range(2, lim + 1):
        if a != i and a % i == 0: return False
    else: return True

N = int(input())
A = [int(input()) for n in range(N+1)]

primes = [int(i) for i in range(2, N+1)]
primes = set(primes)
for i in range(2, N+1):
    temp = set()
    for p in primes:
        if p % i > 0 or p == i: temp |= {p}
    primes = temp

ans = []
for p in primes:
    for i in range(p-1):
        coefficient = 0
        index_a = i
        while index_a <= N:
            coefficient += A[index_a] % p
            coefficient %= p
            index_a += p-1
        if coefficient % p > 0: break
    else: ans.append(p)
        
gcd_of_A = abs(A[N])
for a in A:
    if a != 0: gcd_of_A = gcd(abs(a), gcd_of_A)

commondiv = divisor(gcd_of_A)
for d in commondiv:
    if d > N and is_prime(d): ans.append(d)

ans.sort()
for a in ans: print(a)


### FIXED CODE ###

def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0:
        a, b = b, a%b
    return b

def divisor(a):
    i = 1
    divset = set()
    while i * i <= a:
        if a % i == 0: divset |= {i, a//i}
        i += 1
    divset.remove(1)
    return divset

def is_prime(a):
    if a <= 3: 
        prime = [False, False, True, True]
        return prime[a]
    i = 2
    while i * i <= a:
        if a % i == 0: return False
        i += 1
    else: return True

N = int(input())
A = [None] * (N+1)
for i in reversed(range(N+1)):
    A[i] = int(input())

primes_bool = [True] * (N + 1)
primes = []
for p in range(2, N+1):
    if primes_bool[p]:
        primes.append(p)
        p_mult = p * 2
        while p_mult <= N:
            primes_bool[p_mult] = False
            p_mult += p

ans = []
used = set()
gcd_of_A = abs(A[N])
for a in A[:N]:
    if a != 0: gcd_of_A = gcd(abs(a), gcd_of_A)

commondiv = divisor(gcd_of_A)
for d in commondiv:
    if d > 1 and is_prime(d): 
        ans.append(d)
        used |= {d}

for p in primes:
    if A[0] % p == 0:
        for i in range(1, p):
            coefficient = 0
            index_a = i
            while index_a <= N:
                coefficient += A[index_a]
                coefficient %= p
                index_a += p-1
            if coefficient > 0: break
        else:
            if p not in used: ans.append(p)

ans.sort()
for a in ans: print(a)
s = input().split()
ans = 'No'
for e in s:
  if e = '7':
    ans = 'Yes'
    break
print(ans)


### FIXED CODE ###

s = input()
ans = 'No'
for e in s:
  if e == '7':
    ans = 'Yes'
    break
print(ans)
N= int(input())

graph = {i+1:[] for i in range(N)}

for i in range(N-1):
    a, b, c = map(int, input().split())
    graph[a].append((b, c))
    graph[b].append((a, c))
    
Q, K = map(int, input().split())
visited = [0 for _ in range(N+1)]

def DFS(a, b, c):
    for i, j in graph[b]:
        if(i != a):
            visited[i] = c+j
            DFS(b, i, c+j)
DFS(-1, K, 0)
             
for i in range(Q):
    x, y = map(int, input().split())
    print(visited[x]+visited[y])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

N = int(input())

graph = [[] for _ in range(N)]

for _ in range(N-1):
    a, b, c = map(int, input().split())
    graph[a-1].append((b-1, c))
    graph[b-1].append((a-1, c))
    
Q, K = map(int, input().split())
visited = [0 for _ in range(N)]

def DFS(a, b, c):
    for i, j in graph[b]:
        if(i != a):
            visited[i] = c+j
            DFS(b, i, c+j)
DFS(-1, K-1, 0)
             
for _ in range(Q):
    x, y = map(int, input().split())
    print(visited[x-1]+visited[y-1])
n,m = map(int,input().split())
lis = [[] for i in range(n)]
lnum = [0]*100001
query = []

for _ in range(m):
  tp = tuple(map(int,input().split()))
  query.append(tp)
  lis[tp[0]-1].append(tp[1])
  
for i in range(n):
  lis[i].sort()

for pref in lis:
  for i,city in enumerate(pref):
    lnum[city] = i
  
for item in query:
  print("{:06}{:06}".format(item[0],lnum[item[1]]+1))

### FIXED CODE ###

n,m = map(int,input().split())
lis = [[] for i in range(n)]
query = []

for num in range(m):
  tp = tuple(map(int,input().split()))
  query.append(tp)
  lis[tp[0]-1].append((tp[1],num))  

ans = [[0,0] for i in range(m)]

for num_p , pref in enumerate(lis):
  pref.sort(key = lambda tp:tp[0])
  for i,tp_city in enumerate(pref):
    ans[tp_city[1]][0] = num_p
    ans[tp_city[1]][1] = i+1

for item in ans:
  print("{:06}{:06}".format(item[0]+1,item[1]))
n,m,k=map(int,input().split())

#[index,parent]
unionfind=[[i,-1] for i in range(n)]
friendlist=[set() for _ in range(n)]
blocklist=[set() for _ in range(n)]

def findroot(ind):
    if(unionfind[ind][1]==-1):
        return unionfind[ind][0]
    else:
        return findroot(unionfind[ind][1])

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

    if(findroot(a) != findroot(b)):
        unionfind[findroot(b)][1]=unionfind[findroot(a)][0]

for i in range(k):
    c,d=map(int,input().split())
    c-=1
    d-=1
    blocklist[c].add(d)
    blocklist[d].add(c)

grouplist={}
for i in range(n):
    rooti=findroot(i)
    groupi=grouplist.get(rooti, set())
    groupi.add(i)
    grouplist[rooti]=groupi

# print(unionfind)
# print(friendlist)
# print(blocklist)
# print(grouplist)

ans=[]
for i in range(n):
    ans.append(len(grouplist[findroot(i)] - friendlist[i] - blocklist[i] ) - 1)
print(*ans)


### FIXED CODE ###

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

class UnionFind:
    def __init__(self,n):
        self.group=[i for i in range(n)]
        self.size=[1 for i in range(n)]

    def find(self,x):
        if(self.group[x]==x):
            return x
        else:
            return self.find(self.group[x])

    def unite(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if(x==y):
            pass
        elif(self.sizeof(y) > self.sizeof(x)):
            self.group[x] = self.group[y]
            self.size[y] += self.size[x]
            self.size[x]=0
        else:
            self.group[y] = self.group[x]
            self.size[x] += self.size[y]
            self.size[y]=0

    def sizeof(self,a):
        return self.size[self.find(a)]

    def same(self,x,y):
        return self.find(x)==self.find(y)

uf=UnionFind(n)
friends=[0 for _ in range(n)]
blocks=[0 for _ in range(n)]


for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    friends[a]+=1
    friends[b]+=1
    uf.unite(a,b)

for i in range(k):
    c,d=map(int,input().split())
    c-=1
    d-=1
    if(uf.same(c, d)):
        blocks[c]+=1
        blocks[d]+=1

ans=[]
for i in range(n):
    ans.append(uf.sizeof(i) - friends[i] - blocks[i]  - 1)
print(*ans)
# -*- coding: utf-8 -*-
import numpy as np

x = int(input())
s_candidates = []


for i in range(1, x):
    if x % i == 0:
        s_candidates.append(i)

for s in s_candidates:
    for a in range(x):
        b = a - s
        t = x / s
        tmp = a**4 + (a**3) * b + (a**2) * (b**2) + a * (b**3) + b**4
        if t == tmp:
            ans_a = a
            ans_b = b
            break
    if t == tmp:
        break

print(ans_a, ans_b)


### FIXED CODE ###

# -*- coding: utf-8 -*-
import numpy as np

x = int(input())
flg = 0

for i in range(1, x+1):
    if x % i != 0:
        continue
    else:
        for a in range(x):
            b = a - i
            if a**5 - b**5 == x:
                ans_a = a
                ans_b = b
                flg = 1
                break
            elif a > i and a**5 - b**5 > x:
                flg = -1
                break
        if flg == 1:
            break
        elif flg == -1:
            flg = 0
            continue

print(ans_a, ans_b)
n==int(input())

a==int(n%9)

if a==0:
   print("Yes")
else:
  print("No")
  


### FIXED CODE ###

n=int(input())

a=int(n%9)

if a==0:
   print("Yes")
else:
  print("No")
INF = float('inf')
from bisect import bisect
N = int(input())
A = list(map(int,input().split()))
S = [0]*N
for i in range(N):
    S[i] = S[i-1]+A[i]

ans = INF
i = bisect(S,S[-1]/2)
for r in {i,min(i+1,N-2)}:
    l = S[:r]
    r = S[r:]
    j = bisect(l,l[-1]/2)
    k = bisect(r,(r[-1]+l[-1])/2)
    for p in {j-1,min(j,i-2)}:
        for q in {k-1,min(k,N-i-2)}:
            a,b,c,d = l[p],l[-1]-l[p],r[q]-l[-1],r[-1]-r[q]
            m = min(a,b,c,d)
            M = max(a,b,c,d)
            ans = min(ans,M-m)

print(ans)

### FIXED CODE ###

INF = float('inf')
from bisect import bisect
N = int(input())
A = list(map(int,input().split()))
S = [0]*N
for i in range(N):
    S[i] = S[i-1]+A[i]

ans = INF
for i in range(2,N-1):
    j = bisect(S,S[i-1]/2)
    k = bisect(S,(S[-1]+S[i-1])/2)
    for p in {j-1,min(j,i-2)}:
        for q in {k-1,i,min(k,N-2)}:
            a,b,c,d = S[p],S[i-1]-S[p],S[q]-S[i-1],S[-1]-S[q]
            m = min(a,b,c,d)
            M = max(a,b,c,d)
            ans = min(ans,M-m)

print(ans)
import sys
sys.setrecursionlimit(1500)
n=int(input())
arr=list(map(int,input().split()))
print(arr)
vis={}
vis[0] = 0
vis[1] = 0
def count(n):
    if n in vis:
        return vis[n]
    if n == 2:
        vis[n]=(abs(arr[n-1]-arr[n-2])+count(n-1))
    else:
        vis[n]=min(abs(arr[n-1]-arr[n-2])+count(n-1),abs(arr[n-1]-arr[n-3])+count(n-2))
    return vis[n]
print(count(n))

### FIXED CODE ###

n=int(input())
arr=list(map(int,input().split()))
if n < 2:
  print(0)
vis = [0] * n
vis[0] = 0
vis[1] = abs(arr[0]-arr[1])
for i in range(2, n):
    step_1 = abs(arr[i]-arr[i-1]) + vis[i-1]
    step_2 = abs(arr[i]-arr[i-2]) + vis[i-2]
    vis[i] = min(step_1, step_2)
print(vis[-1])
import collections
s = list(input())
sset = set(s)
if len(sset) != 26:
    for i in range(97,123):
        if chr(i) in sset:
            continue
        else:
            tmp = chr(i)
            s.append(tmp)
            break

    print(''.join(s))
    exit()
else:
    tmp = []
    flg = False
    s = s[::-1]
    for i in range(1,26):
        if ord(s[i-1]) < ord(s[i]) and not flg:
            flg = True
            tmp.append(ord(s[i-1]))
            tmp.append((ord(s[i])))
            continue
        if flg and ord(s[i-1]) > ord(s[i]):
            top = i
            break
        if ord(s[i-1]) < ord(s[i]) and flg:
            tmp.append(ord(s[i]))

    if len(tmp) == 26:
        print(-1)
        exit()
    ans = s[top:]
    ans = ans[::-1]
    ans.append(chr(min(tmp)))
    print(''.join(ans))


### FIXED CODE ###

import collections
s = list(input())
sset = set(s)
if len(sset) != 26:
    for i in range(97,123):
        if chr(i) in sset:
            continue
        else:
            tmp = chr(i)
            s.append(tmp)
            break

    print(''.join(s))
    exit()
else:
    tmp = []
    flg = False
    for i in range(1,26):
        if s[i-1] < s[i]:
            tmp.append(i-1)
            continue

    if len(tmp) == 0:
        print(-1)
        exit()
    change_i = max(tmp)
    if change_i == 0:
        print(chr(ord(s[0])+1))
        exit()
    ans = s[:change_i]
    for i in range(97,123):
        if chr(i) in ans:
            continue
        else:
            if ord(s[change_i]) < i:
                ans.append(chr(i))
                break
    print(''.join(ans))
import math

n = int(input())
c = [[0]*2 for i in range(n) ]
a = [0] * n
p = math.pi
for i in range(n):
    c[i][0], c[i][1] = map(float, input().split())

def f(ax, ay, bx, by, cx, cy):
    vx = ax - cx
    vy = ay - cy
    wx = bx - cx
    wy = by - cy
    s = 1
    if vx * wy - vy * wx < 0: s = -1
    p = vx * wx + vy * wy
    q = ( vx * vx + vy * vy ) ** 0.5
    r = ( wx * wx + wy * wy ) ** 0.5
    t = p / (q * r)
    t = max(-1, min(1, t))
    t = (math.acos( p / (q * r) )) * s
    return t

for i in range(n):
    k = (i+1)%n
    tax = 0
    tin = 0
    for j in range(n):
        if j != i and j != k:
            t = f(c[k][0], c[k][1], c[j][0], c[j][1], c[i][0], c[i][1])
            tax = max(tax, t)
            tin = min(tin, t)
    if tax - tin < p:
        a[i] = (p - tax + tin) / (p * 2)

for i in range(n):
    print(round(a[i], 6))


### FIXED CODE ###

import math

n = int(input())
c = [[0]*2 for i in range(n) ]
a = [0] * n
p = math.pi
for i in range(n):
    c[i][0], c[i][1] = map(float, input().split())

def f(ax, ay, bx, by, cx, cy):
    vx = ax - cx
    vy = ay - cy
    wx = bx - cx
    wy = by - cy
    s = 1
    if vx * wy - vy * wx < 0: s = -1
    p = vx * wx + vy * wy
    q = ( vx * vx + vy * vy ) ** 0.5
    r = ( wx * wx + wy * wy ) ** 0.5
    t = p / (q * r)
    t = max(-1, min(1, t))
    t = (math.acos( t )) * s
    return t

for i in range(n):
    k = (i+1)%n
    tax = 0
    tin = 0
    for j in range(n):
        if j != i and j != k:
            t = f(c[k][0], c[k][1], c[j][0], c[j][1], c[i][0], c[i][1])
            tax = max(tax, t)
            tin = min(tin, t)
    if tax - tin < p:
        a[i] = (p - tax + tin) / (p * 2)

for i in range(n):
    print(round(a[i], 6))
l = list(map(int, input().split()))
l = sorted(l)
ans = 0
for i in range(n):
  a = l[i]
  for j in range(i + 1, n):
    b = l[j]
    bel1 = j #OK
    up1 = n #OUT
    while up1- bel1 > 1:
      mid = (bel1 + up1)//2
      if a + b > l[mid]:
        bel1 = mid
      else:
        up1 = mid
    ans += (bel1-j)
print(ans)

### FIXED CODE ###

import bisect
n = int(input())
l = sorted(list(map(int,input().split())))
ans = 0
 
for i in range(n-2):
    for j in range(i+1, n-1):
        ans += bisect.bisect_left(l,l[i] + l[j]) - j - 1
print(ans)
from math import gcd
A,B,K=map(int,input().split())
C=gcd(A,B)
count=0
for x in range(1,C+1):
    if C%x==0:
        count+=1
        if count==K:
            print(x)
            break

### FIXED CODE ###

import fractions
A,B,K=map(int,input().split())
C=fractions.gcd(A,B)
cnt=0
for x in range(C,0,-1):
    if C%x==0:
        cnt+=1
        if cnt==K:
            print(x)
            break
def main():
    x = int(input())

    i = 0
    while True:
        j = i ** 5
        a1, a2 = x + j, x - j

        p = a1 ** (1 / 5)
        if int(p) == p:
            p = int(p)
            print(p, j)
            break
        if a2 >= 0:
            p = a2 ** (1 / 5)
            if int(p) == p:
                p = int(p)
                print(p, -1 * j)
                break
        else:
            p = abs(b2) ** (1 / 5) * -1
            if int(p) == p:
                p = int(p)
                print(p, -1 * j)
                break
        i += 1


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    x = int(input())
    for i in range(150, 0, -1):
        for j in range(i, -150, -1):
            cal = i ** 5 - j ** 5
            if cal == x:
                print(i, j)
                exit()


if __name__ == '__main__':
    main()
N=int(input())
A=[]
for i in range(N):
    a,b=map(int,input().split())
    c=a-b
    A.append([a,-b])
A.sort()
ao=0
t=0
for j in range(N):
    if j%2==0:
        ao+=A[j][0]
    else:
        t+=A[j][1]
print(ao+t)


### FIXED CODE ###

N,A,B=map(int,input().split())
print(min(A,B),max(A+B-N,0))
import sys
sys.setrecursionlimit(2 * 10**5)

N = int(input())
X = [i for i in input()]
sum_X = X.count("1")


def division_binary_shift(a, b):
    """
    a // b

    :param a: dividend
    :param b: divisor
    :return: quotient
    """
    if a < b:
        return 0
    if b == 0:
        raise ZeroDivisionError

    q = 0
    sq = 1
    ori_b = b
    while a >= b:
        b <<= 1
        if a >= b:
            sq <<= 1
        else:
            b >>= 1
            a -= b
            q += sq
            sq = 1
            b = ori_b

    return a


def f(n, p):
    res = division_binary_shift(int(n, 2), p)
    if res != 0:
        temp2 = format(res, "b")
        return f(temp2, temp2.count("1")) + 1
    return 1


for i in range(0, N):
    tempX = ""
    count = sum_X
    if X[i] == "0":
        count += 1
        X[i] = "1"
        tempX = "".join(X)
        X[i] = "0"
    else:
        count -= 1
        X[i] = "0"
        tempX = "".join(X)
        X[i] = "1"

    print(f(tempX, count))

### FIXED CODE ###

N = int(input())
X = input()
X_i = int(X, 2)
X_b = bin(X_i)
sum_X = X_b.count("1")
Xp = X_i % (sum_X + 1)
Xm = X_i % (sum_X - 1) if sum_X - 1 > 0 else -1


def f(n, p):
    count = 1
    n %= p
    while n != 0:
        p = bin(n).count("1")
        n %= p
        count += 1
    return count


for i in range(1, N + 1):
    if X[i - 1] == "1":
        if sum_X - 1 <= 0:
            print(0)
            continue
        nm = pow(2, N - i, sum_X - 1)
        print(f(Xm - nm, sum_X - 1))
    else:
        np = pow(2, N - i, sum_X + 1)
        print(f(Xp + np, sum_X + 1))
n=int(input())

result=[]
for i in range(1,n+1):
    if i %3==0:
        result.append(i)
    else:
        k=i
        for j in range(1,len(str(n)+1):
            if k%(10**j)==3:
                result.append(i)
                break
            else:
                k=k//10**j
        else:
            continue

r=" "+" ".join(result)
print(r)

### FIXED CODE ###

n=int(input())
 
result=[]
for i in range(1,n+1):
    if i %3==0:
        result.append(i)
    else:
        k=i
        for j in range(1,5):
            if k%10==3:
                result.append(i)
                break
            else:
                k=k//10
        else:
            continue
 
print("",*result)
def main():
    a, b, c = map(int, input().split())
    sum = a+b+c
    print(sum)

    if (sum <=  21):
        print("win")
    elif(sum >= 22):
        print("bust")

if __name__ == "__main__":
    main()

### FIXED CODE ###


def main():
    a, b, c = map(int, input().split())
    sum = a+b+c

    if (sum <=  21):
        print("win")
    elif(sum >= 22):
        print("bust")

if __name__ == "__main__":
    main()
n,m = map(int,input().split())
digit = ['-2']*n
for i in range(m):
    s,c = input().split()
    s = int(s)
    if digit[s-1] == '-2' or digit[s-1] == c:
        digit[s-1] = c
    else:
        digit[s-1] = '-1'
if ('-1' in digit) or (len(digit)!=1 and digit[0] == '0'):
    print(-1)
else:
    print("".join(digit.replace('-2','0')))

### FIXED CODE ###

n,m = map(int,input().split())
digit = ['-2']*n
for i in range(m):
    s,c = input().split()
    s = int(s)
    if digit[s-1] == '-2' or digit[s-1] == c:
        digit[s-1] = c
    else:
        digit[s-1] = '-1'
if ('-1' in digit) or (len(digit)!=1 and digit[0] == '0' and digit[1] == '-2'):
    print(-1)
else:
    if digit[0] != '-2' or (len(digit)==1 and digit[0] == '-2'):
        print("".join(digit).replace('-2','0'))
    else:
        digit[0] = '1'
        print("".join(digit).replace('-2','0'))
a,b,c=map(int,input())
print("Yes" if a<=c<=b else "No")

### FIXED CODE ###

a,b,c=map(int,input().split())
print("Yes" if a<=c<=b else "No")
a,b=map(int,input().split())
ans=1
bb=b-a
while bb=>0:
  bb=bb-(a-1)
  ans+=1
print(ans)

### FIXED CODE ###

a,b=map(int,input().split())
if b==1:
	print(0)
else:
	ans=1
	bb=b-a
	while bb>0:
  		bb=bb-(a-1)
  		ans+=1
	print(ans)
import sys
input=sys.stdin.readline

D=int(input().rstrip('\n'))
cs=[int(x) for x in input().rstrip('\n').split()]
S={}
cd=[0]*26
for i in range(D):
  S[i] = [int(x) for x in input().rstrip('\n').split()]
for i in range(D):
  s1 = S[i]
  s1_s=sorted(s1,reverse=True)
  if i!=D-1:
    s2=S[i+1]
    s1_a=[x-y for x,y in zip(s1,cd)]
    s2_i=[x-y for x,y in zip(s2,cd)]
    if s2.index(max(s2_i))==s1.index(max(s1_a)):
      x = s1.index(sorted(s1_a,reverse=True)[1])+1
      cd = [y+z for y,z in zip(cd,cs)]
      cd[x-1]=0
      print(x)
    else:
      print(s1.index(sorted(s1_a,reverse=True)[0])+1)
print(S[D-1].index(max(S[D-1]))+1)


### FIXED CODE ###

import sys
input=sys.stdin.readline

D=int(input().rstrip('\n'))
cs=[int(x) for x in input().rstrip('\n').split()]
for i in range(D):
  Ss = [int(x) for x in input().rstrip('\n').split()]
  print(Ss.index(max(Ss))+1)