Harryxun/stf_run huggingface dataset:
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

import math

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

N, K = nl()
prev_a = 0
prev_b = 0
for i in range(1, K+1):
    print(fac(N-K+1, i) * fac(K-1, i-1) % 1000000007)



### FIXED CODE ###

nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

import math

def fac(n, r):
    if r > n:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N, K = nl()
prev_a = 0
prev_b = 0
for i in range(1, K+1):
    print(fac(N-K+1, i) * fac(K-1, i-1) % 1000000007)
import math
N,K = map(int,input().split())
def combinations_count(n, r):
    return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))

for i in range(1,K+1):
    if N-K+1-i<0:
        print(0)
    else:
        print(int(combinations_count(N-K+1, i)*combinations_count(K-1, i-1)%1000000007))


### FIXED CODE ###

import math
N,K = map(int,input().split())
def combinations_count(n, r):
    return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))

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

mod = 1000000007
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 )

for i in range(1,K+1):
    # print(i)
    if N-K+1-i<0:
        print(0)
    else:
        first = int(cmb(N-K+1, i,mod))
        last  = int(cmb(K-1, i-1,mod))
        print((first*last)%mod)
x = str(input())

if x="AAA" or x="BBB":
  print("Yes")
else:
  print("No")
  


### FIXED CODE ###

x = input()

if x[0]==x[1]==x[2]:
  print("No")
else:
  print("Yes")
N,M = map(int, input().split())
if N != 1:
    answer = ['0']* (N-1)
    answer.insert(0,'1')
else:
    answer =['0']
s_list = []
c_list = []
end = 0
for i in range(0,M):
    s, c = map(int, input().split())
    answer[s-1]= str(c)
    s_list.append(s)
    c_list.append(c)
    for i in range(0,len(s_list)):
        if (s_list[i] == s) &  (c_list[i] != c):
            end =1
            break

if end == 1:
    print(''-1)
elif (len(answer) == 1) & (answer[0]=='0'):
    print(0)
elif answer[0] == '0':
    print(-1)
else:
    print(int(''.join(answer)))



### FIXED CODE ###


N,M = map(int, input().split())
if N != 1:
    answer = ['0']* (N-1)
    answer.insert(0,'1')
else:
    answer =['0']
s_list = []
c_list = []
end = 0
for i in range(0,M):
    s, c = map(int, input().split())
    answer[s-1]= str(c)
    s_list.append(s)
    c_list.append(c)
    for i in range(0,len(s_list)):
        if (s_list[i] == s) &  (c_list[i] != c):
            end =1
            break

if end == 1:
    print(-1)
elif (len(answer) == 1) & (answer[0]=='0'):
    print(0)
elif answer[0] == '0':
    print(-1)
else:
    print(int(''.join(answer)))
n = int( input() )
#print( n )

cnt = 0
for i in range( n ):
    a, b = map( int, input().split() )
    if a == b:
        cnt = cnt + 1
    else:
        cnt = 0

    if cnt == 3:
        exit( "Yes" )


print( "No" )


### FIXED CODE ###

n = int( input() )
#print( n )

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

    if cnt == 3:
        ans = "Yes"


print( ans )
def pickup(S,ans):
    l = len(S)
    if l<2:
        return ans
    check_dif = False
    #print(S)
    for i in range(l-1):
        if S[i] != S[i+1]:
            S.pop(i)
            S.pop(i)
            #print(S)
            check_dif = True
            ans += pickup(S,ans)
            break
    if not check_dif:
        return ans
    else:
        return ans+2
    
S=input()
S_list = []
l = len(S)
for i in range(l):
    S_list.append(S[i])
ans =0
print(pickup(S_list,ans))

### FIXED CODE ###

S=input()
num_one=S.count('1')
num_zero=S.count('0')
ans = 2*min(num_one,num_zero)
print(ans)
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n)]
ans = []
for i in range(n, 0, -1):
    if a[i-1] == 0:
        tmp = 0
        j = i * 2
        while j < n:
            # print(j)
            tmp += b[j-1]
            j += i
        if tmp % 2 == 0:
            b[i-1] = 0
        else:
            b[i-1] = 1
    else:
        tmp = 0
        j = i * 2
        while j < n:
            # print(j-1)
            tmp += b[j-1]
            j += i
        if tmp % 2 == 1:
            b[i-1] = 0
        else:
            b[i-1] = 1

for i in range(n):
    if b[i] % 2 != 0:
        # print(b[i]%2)
        ans.append(a[i+1])
# print(b)
print(len(ans))
for i in ans:
    print(i)

### FIXED CODE ###

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

input_num = [0 for _ in range(n)]

for i in range(n-1, -1, -1):
    tmp = 0
    j = i+i+1
    while j < n:
        tmp += input_num[j]
        j += i+1

    if tmp % 2 != a[i]:
        input_num[i] = 1

print(sum((input_num)))
for i, j in enumerate(input_num):
    if j:
        print(i+1, end=' ')
N,M=map(int,input().split())
A=[input() for _ in range(N)]
B=[input() for _ in range(M)]
ans="No"
for i in range(N-M+1):
  for j in range(len(A[0])-len(B[0])+1):
    t = 0
    for k in range(len(B[0])):
      for l in range(M):
        if A[k+q][l+p] == B[q][p]:
          t += 1
    if t==len(B[0])*M:
      ans="Yes"
      break
print(ans)

### FIXED CODE ###

N,M=map(int,input().split())
A=[input() for _ in range(N)]
B=[input() for _ in range(M)]
ans="No"
for i in range(N-M+1):
  for j in range(N-M+1):
    if [a[j:j+M] for a in A[i:i+M]]==B:    
      ans="Yes"
print(ans)
N, A, B, C = map(int, input().split())
dic = {
    "A": A,
    "B": B,
    "C": C
}
ans = [0] * N
def part_solve(dic, depth):
    while depth < N:
        key1, key2 = inputs[depth]
        if dic[key1] < dic[key2]:
            dic[key1] += 1
            dic[key2] -= 1
            ans[depth] = key1
        elif dic[key1] > dic[key2]:
            dic[key2] += 1
            dic[key1] -= 1
            ans[depth] = key2
        else:
            if not dic[key1]:
                return False
            else:
                key3 = "ABC".replace(key1, "").replace(key2, "")
                return part_solve({
                    key1: dic[key1] + 1,
                    key2: dic[key2] - 1,
                    key3: dic[key3]
                }, depth) or part_solve({
                    key1: dic[key1] - 1,
                    key2: dic[key2] + 1,
                    key3: dic[key3]
                }, depth)
        depth += 1
    return True

inputs = tuple(tuple(input()) for _ in range(N))
if part_solve(dic, 0):
    print("Yes")
    print(*ans, sep="\n")
else:
    print("No")


### FIXED CODE ###

N, A, B, C = map(int, input().split())
inputs = tuple(tuple(input()) for _ in range(N))

dic = {
    "A": A,
    "B": B,
    "C": C
}

ans = [0] * N
depth = 0
while depth < N:
    key1, key2 = inputs[depth]
    if dic[key1] < dic[key2]:
        dic[key1] += 1
        dic[key2] -= 1
        ans[depth] = key1
    elif dic[key1] > dic[key2]:
        dic[key2] += 1
        dic[key1] -= 1
        ans[depth] = key2
    else:
        if not dic[key1]:
            break
        elif dic[key1] == 1 and depth + 1 < N:
            next_key1, next_key2 = inputs[depth + 1]
            common_key, *_ = {key1, key2} & {next_key1, next_key2}
            else_key, *_ = {key1, key2} - {common_key}
            dic[common_key] += 1
            dic[else_key] -= 1
            ans[depth] = common_key
        else:
            dic[key1] += 1
            dic[key2] -= 1
            ans[depth] = key1
    depth += 1
else:
    print("Yes")
    print(*ans, sep="\n")
    quit()
print("No")
import sys
input = sys.stdin.read


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

abslsta=[abs(v) for v in lsta]
min_index=abslsta.index(min(abslsta))

for i in range(n-1):
    if lsta[i]<0:
        lsta[i]=lsta[i]*(-1)
        lsta[i+1]=lsta[i+1]*(-1)

if lsta[n-1]<0:
    if min_index==n-1:
        print(sum(lsta))

    else:
        print(sum(lsta)-lsta[n-1]*2-lsta[min_index]*2)

else:
    print(sum(lsta))

### FIXED CODE ###

#import sys
#input = sys.stdin.read

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

abslsta=[abs(v) for v in lsta]
min_index=abslsta.index(min(abslsta))

for i in range(n-1):
    if lsta[i]<0:
        lsta[i]=lsta[i]*(-1)
        lsta[i+1]=lsta[i+1]*(-1)

if lsta[n-1]<0:
    if min_index==n-1:
        print(sum(lsta))

    else:
        print(sum(lsta)-lsta[n-1]*2-lsta[min_index]*2)

else:
    print(sum(lsta))
import sys


def dep(u, p):
    D[u] = p
    if tree[u][2] != NIL:
        dep(tree[u][2], p)
    if tree[u][1] != NIL:
        dep(tree[u][1], p+1)


def print_ans():
    for i in range(n):
        print("node {}: parent = {}, depth = {}, {}, {}"
              .format(i, tree[i][0], D[i], tree[i][4], tree[i][3]))


if __name__ == "__main__":
    NIL = -1
    n = int(sys.stdin.readline())
    tree = [[NIL, NIL, NIL] for i in range(n)]
    D = [0 for i in range(n)]
    for a in sys.stdin.readlines():
        a = list(map(int, a.split()))
        tree[a[0]].append(a[2:])
        if a[1] > 0:
            tree[a[0]][1] = a[2]    # ???????????????
            for i in range(a[1]):
                tree[a[i+2]][0] = a[0] # ????????????
                if i != a[1] - 1:
                    tree[a[i+2]][2] = a[i+3] # ??????????????????
    for i in range(n):
        if tree[i][0] == NIL:
            tree[i].append("root")
            r = i
        elif tree[i][1] == NIL:
            tree[i].append("leaf")
        else:
            tree[i].append("internal node")
    dep(r, 0)
    print_ans()

### FIXED CODE ###

import sys


def dep(u, p):
    D[u] = p
    for i in tree[u][3]:
        dep(i, p+1)


def print_ans():
    for i in range(n):
        print("node {}: parent = {}, depth = {}, {}, {}"
              .format(i, tree[i][0], D[i],
                      "root" if tree[i][0] == NIL else "leaf" if tree[i][1] == NIL else "internal node",
                      tree[i][3]))


if __name__ == "__main__":
    NIL = -1
    n = int(sys.stdin.readline())
    tree = [[NIL, NIL, NIL] for i in range(n)]
    D = [0 for i in range(n)]
    root = set(range(n))
    for a in sys.stdin.readlines():
        a = list(map(int, a.split()))
        tree[a[0]].append(a[2:])
        if a[1] > 0:
            tree[a[0]][1] = a[2]    # ???????????????
            for i in range(a[1]):
                tree[a[i+2]][0] = a[0] # ????????????
                if i != a[1] - 1:
                    tree[a[i+2]][2] = a[i+3] # ??????????????????
        root -= set(a[2:])
    dep(root.pop(), 0)
    print_ans()
a,b=map(int,input.split())
if a%b:
  print(1)
else:
  print(0)

### FIXED CODE ###

#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N, K = map(int, input().split())
if N%K==0:
    print(0)
else:
    print(1)
n = int(input())
a = list(map(int, input().split()))
 
dp = [0] * n
dp[0] = 0
dp[1] = abs(a[0] - a[1])
dp[2] = dp[0]
for i in range(2, n):
  dp[i] = min(dp[i-2] + abs(a[i-2] - a[i]) , d[i - 1] + abs(a[i - 1] - a[i]))
 
print dp[n - 1]  

### FIXED CODE ###

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

dp = [0] * n
dp[0] = 0
dp[1] = abs(a[0] - a[1])

for i in range(2, n):
  dp[i] = min(dp[i-2] + abs(a[i-2] - a[i]) , dp[i - 1] + abs(a[i - 1] - a[i]))

print(dp[n - 1])
import collections

N,K,Q = map(int,input().split())
lst =[int(input()) for i in range (Q)]

if K > Q :
    for i in range(N):
        print('Yes')
    exit(0)
else:
    x = Q - K

#s = set(lst)
c = collections.Counter(lst)

values, counts = zip(*c.most_common(x))

if len(values) == 0 :
    for i in range(N):
        print('No')
    exit(0)
    

#print(values)
#print(type(values))
newlist = sorted(values)
j = 0
l = len(values)
for i in range(N):
    if l-1 >= j :
        if i +1 == values[j] :
            print('Yes')
            j += 1
        else:
            print('No')
    else:
        print('No')



### FIXED CODE ###

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

lst = [0] * N

for i in range(Q):
    lst[int(input())-1] += 1

x = Q - K 

for i in range(len(lst)):
    if lst[i] - x > 0 :
        print('Yes')
    else:
        print('No')
n,d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]

cnt=0
for i in range(n):
    for j in range(i+1,n):
        for k in range(d):
            sum=0
            sum += (x[i][k]-x[j][k])**2
        route = sum**0.5
        if route.is_integer:
        cnt += 1
        
print(cnt)

### FIXED CODE ###

n,d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
cnt=0

for i in range(n):
    for j in range(i+1,n):
        distance=0
        for k in range(d):
            distance += (x[i][k]-x[j][k])**2
        if (distance**0.5).is_integer():
            cnt += 1
print(cnt)
a,b = map(int,input().split())
if a < b:
    print('{}<{}'.format(a,b))
elif a > b:
    print('{}>{}'.format(a,b))
elif: a == b
    print('{}=={}'.format(a,b))

### FIXED CODE ###

a,b = map(int,input().split())
if a < b:
    print('a < b')
elif a > b:
    print('a > b')
else:
    print('a == b')
n = int(input())
s = str(input())
count = 0
for i in range(n):
    for j in range(n):
        for k in range(n):
            if i < j < k:
                a = (s[i], s[j], s[k])
                #print(a)
                a_set = set(a)
                #print(a_set)
                if len(a_set) == 3 and (j - i) != (k - j):
                    count += 1
print(count)

### FIXED CODE ###

n = str(input())
flag = True
for i in range(3):
    if n[i] == "7":
        print("Yes")
        flag = False
        break
if flag:
    print("No")
a, b = list(map(int, input().split()))
if a == 1:
  a = 14
else:
  break
if b == 1:
  b = 14
else:
  break
if a > b:
  print('Alice')
elif a == b:
  print('Draw')
else:
  print('Bob')


### FIXED CODE ###

a, b = list(map(int, input().split()))
if a == 1:
  a = 14
else:
  a = a
if b == 1:
  b = 14
else:
  b = b
if a > b:
  print('Alice')
elif a == b:
  print('Draw')
else:
  print('Bob')
nm_lst = list(map(int, input().split()))
city_lst = [list(map(int, (str(i)+' '+input()).split())) for i in range(nm_lst[1])]

city_lst = sorted(city_lst, key = lambda x: x[1]*10**7 + x[2])

ans_lst = []
num_num = 0
for n, city in enumerate(city_lst):
    prefec_num = city[1]
    prefec_str = '0' * (6-len(str(prefec_num))) + str(prefec_num)
    if n = 0 or (prefec_num != city_lst[n-1][1]):
        num_str = '000001'
        num_num = 1
    else:
        num_num += 1
        num_str = '0' * (6-len(str(num_num))) + str(num_num)
    ans_lst.append([city[0], prefec_str, num_str])
    
ans_lst = sorted(ans_lst, key = lambda x:x[0])

for city in ans_lst:
    print(city[1]+city[2])

### FIXED CODE ###

nm_lst = list(map(int, input().split()))
city_lst = [list(map(int, (str(i)+' '+input()).split())) for i in range(nm_lst[1])]

city_lst = sorted(city_lst, key = lambda x: x[1]*(10**12) + x[2])

ans_lst = []
num_num = 0
for n, city in enumerate(city_lst):
    prefec_num = city[1]
    prefec_str = '0' * (6-len(str(prefec_num))) + str(prefec_num)
    if n == 0 or (prefec_num != city_lst[n-1][1]):
        num_num = 1
    else:
        num_num += 1
    num_str = '0' * (6-len(str(num_num))) + str(num_num)
    ans_lst.append([city[0], prefec_str, num_str])
    
ans_lst = sorted(ans_lst, key = lambda x:x[0])

for city in ans_lst:
    print(city[1]+city[2])
S = input()
T = input()

for i in range(len(S)):
	if S==T
		print("Yes")
		break
	S = S[-1]+ S[:-1]
else:
	print("No")

### FIXED CODE ###

S = input()
T = input()

for i in range(len(S)):
	if T==S:
		print("Yes")
		break
	S = S[-1]+ S[0:-1]
else:
	print("No")
def main(n, t, m, p_x):
    for p, x in p_x:
        _t = t.copy()
        _t[p - 1] = x

        print(sum(_t))


if __name__ == "__main__":
    n = int(input())
    t = list(map(int, input().split()))
    m = int(input())
    p_x = [int(input()) for _ in range(m)]

    main(n, t, m, p_x)


### FIXED CODE ###

def main(n, t, m, p_x):
    for p, x in p_x:
        _t = t.copy()
        _t[p - 1] = x

        print(sum(_t))


if __name__ == "__main__":
    n = int(input())
    t = list(map(int, input().split()))
    m = int(input())
    p_x = [list(map(int, input().split()))
    for _ in range(m)]

    main(n, t, m, p_x)
# -*- coding: utf-8 -*-
import numpy as np
from scipy.sparse.csgraph import csgraph_from_dense, dijkstra
def inpl(): return map(int, input().split())

sx, sy, tx, ty = inpl()
N = int(input())
X = np.zeros((1, N+2), dtype=np.float64)
Y = np.zeros((1, N+2), dtype=np.float64)
R = np.zeros((1, N+2), dtype=np.float64)

X[0][0] = sx
Y[0][0] = sy
X[0][N+1] = tx
Y[0][N+1] = ty

for i in range(N):
    X[0][i+1], Y[0][i+1], R[0][i+1] = inpl()

G = np.maximum(np.sqrt(np.square(X-X.T) + np.square(Y-Y.T)) - (R+R.T),
               np.zeros((N+2, N+2), dtype=np.float64))
Gsp = csgraph_from_dense(G, null_value=np.inf)

print(dijkstra(Gsp, indices=0)[-1])


### FIXED CODE ###

# -*- coding: utf-8 -*-
import numpy as np
from scipy.sparse.csgraph import csgraph_from_dense, dijkstra
def inpl(): return map(int, input().split())

sx, sy, tx, ty = inpl()
N = int(input())
X = np.zeros((1, N+2), dtype=np.float64)
Y = np.zeros((1, N+2), dtype=np.float64)
R = np.zeros((1, N+2), dtype=np.float64)

X[0][0] = sx
Y[0][0] = sy
X[0][N+1] = tx
Y[0][N+1] = ty

for i in range(N):
    X[0][i+1], Y[0][i+1], R[0][i+1] = inpl()

G = np.maximum(np.sqrt(np.square(X-X.T) + np.square(Y-Y.T)) - (R+R.T),
               np.zeros((N+2, N+2), dtype=np.float64)) 
G += np.diag(np.ones(N+2, dtype=np.float64)*np.inf)
G = csgraph_from_dense(G, null_value=np.inf)
print(dijkstra(G, indices=0)[-1])
import sys
import heapq
input = sys.stdin.readline
N, M = map(int, input().split())
a = list(map(int, input().split()))
res = 0
if M == 0:
  if N == 1:
    print(0)
  elif N == 2:
    print(sum(a))
  else: print("Impossible")
  exit(0)
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.root = [-1] * (n + 1)
    self.rnk = [0] * (n + 1)

  def Find_Root(self, x):
    if self.root[x] < 0:
      return x
    else:
      self.root[x] = self.Find_Root(self.root[x])
      return self.root[x]

  def Unite(self, x, y):
    x = self.Find_Root(x)
    y = self.Find_Root(y)
    if x == y:
      return 
    elif self.rnk[x] > self.rnk[y]:
      self.root[x] += self.root[y]
      self.root[y] = x
    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      if self.rnk[x] == self.rnk[y]:
        self.rnk[y] += 1

  def isSameGroup(self, x, y):
    return self.Find_Root(x) == self.Find_Root(y)

  def Count(self, x):
    return -self.root[self.Find_Root(x)]

uf = UnionFind(N - 1)
for _ in range(M):
  u, v = map(int, input().split())
  uf.Unite(u, v)
hs = [[] for _ in range(N + 1)]
for x in range(N):
  y = uf.Find_Root(x)
  heapq.heappush(hs[y], a[x])
#print(hs)
c = 0
t = []
for x in range(N):
  if len(hs[x]):
    c += 1
    res += heapq.heappop(hs[x])
    if len(hs[x]): t.append(heapq.heappop(hs[x]))
t.sort()
#print(c, t, hs, res)
if c == 1:
  print(0)
  exit(0)
for i in range(c - 2):
  if i >= c - 2:
    print("Impossible")
    exit(0)
  res += t[i]
print(res)

### FIXED CODE ###

import sys
input = sys.stdin.readline
N, M = map(int, input().split())
a = list(map(int, input().split()))
if N == 1:
  print(0)
  exit(0)
if M == 0 and (N > 2):
  print("Impossible")
  exit(0)
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.root = [-1] * (n + 1)
    self.rnk = [0] * (n + 1)

  def Find_Root(self, x):
    if self.root[x] < 0:
      return x
    else:
      self.root[x] = self.Find_Root(self.root[x])
      return self.root[x]

  def Unite(self, x, y):
    x = self.Find_Root(x)
    y = self.Find_Root(y)
    if x == y:
      return 
    elif self.rnk[x] > self.rnk[y]:
      self.root[x] += self.root[y]
      self.root[y] = x
    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      if self.rnk[x] == self.rnk[y]:
        self.rnk[y] += 1

  def isSameGroup(self, x, y):
    return self.Find_Root(x) == self.Find_Root(y)

  def Count(self, x):
    return -self.root[self.Find_Root(x)]
uf = UnionFind(N)
d = [[] for _ in range(N)]
for _ in range(M):
  u, v = map(int, input().split())
  uf.Unite(u, v)
for i in range(N):
  d[uf.Find_Root(i)].append(a[i])
res = 0
x = []
y = 0
for i in range(N):
  d[i].sort(reverse = True)
  if len(d[i]):
    res += d[i].pop()
    y += 1
  x += d[i]
if y == 1:
  print(0)
  exit(0)
x.sort()
for i in range((y - 1) * 2 - y):
  if i >= len(x):
    print("Impossible")
    exit(0)
  res += x[i]
print(res)
from collections import Counter
n,k,l = map(int, input().split())
def f(m):
    a = [[] for _ in range(n)]
    for _ in range(m):
        p,q = map(int, input().split())
        a[p-1].append(q-1)
        a[q-1].append(p-1)
    b = list(range(n))
    for i in range(n):
        def g(j):
            if b[j] != j:
                return
            b[j] = i
            for k in a[j]:
                g(k)
        g(i)
    return b
a = f(k)
b = f(l)
c = Counter((a[i],b[i]) for i in range(n))
print(' '.join((str(c[a[i],b[i]]) for i in range(n))))

### FIXED CODE ###

from collections import Counter
n,k,l = map(int, input().split())
def f(m):
    a = list(range(n))
    def g(i):
        if a[i] == i:
            return i
        a[i] = g(a[i])
        return a[i]
    for _ in range(m):
        p,q = map(int, input().split())
        i = g(p-1)
        j = g(q-1)
        a[j] = i
    return g
g = f(k)
h = f(l)
c = Counter((g(i),h(i)) for i in range(n))
print(' '.join((str(c.get((g(i),h(i)), 1)) for i in range(n))))
s = input()
n = len(s)

#左から順番に文字を結合していき+を入れるパターンと入れないパターンについて同様に文字を結合させていく
def dfs(i,f):
    if i == n-1:#すべての文字を使いきったらそのときの計算をする
        return sum(list(map(int,f.split("+"))))
    return dfs(i+1,f+s[i+1]) + dfs(i+2,f+"+"+s[i+1])#+を入れない場合、+をいれる場合
    
print(dfs(0,s[0])

### FIXED CODE ###

s = input()
n = len(s)

#左から順番に文字を結合していき+を入れるパターンと入れないパターンについて同様に文字を結合させていく
def dfs(i,f):
    if i == n-1:#すべての文字を使いきったらそのときの計算をする
        return sum(list(map(int,f.split("+"))))
    return dfs(i+1,f+s[i+1]) + dfs(i+1,f+"+"+s[i+1])#+を入れない場合、+をいれる場合
    
print(dfs(0,s[0]))
#まずｎ団目までいく最短コストを探す。それはｎからｋ前までからのうち最短コストとなるもの
import sys #追加
sys.setrecursionlimit(500*500) #追加
def minJ(N,K,costL,memo):
    if N-1 in memo ==True:
        return memo[N-1]
    if N<K:
        return abs(costL[N-1]-costL[0])
    else:
        result=None
        for i in range(1,K+1):
            stock=minJ(N-i,K,costL,memo)+abs(costL[N-1]-costL[N-i-1])
            if result==None or (stock<result):
                result=stock
    memo[N-1]=result
    return result
N=int(input())
K=int(input())
costL=[]
memo={}

for i in range(N):
    costL.append(int(input()))

print(minJ(N,K,costL,memo))

### FIXED CODE ###

import sys
sys.setrecursionlimit(400000000)
def main():
    n,k=map(int,input().split())
    h=tuple(map(int,input().split()))
    flog=[-1]*n
    for i in range(n):#dest=i 0が１
        if i<k+1:#0~k
            flog[i]=abs(h[i]-h[0])
        else:
            min=10**9
            for j in range(1,k+1):#1~k
                tmp=flog[i-j]+abs(h[i]-h[i-j])
                if tmp<min:
                    min=tmp
            flog[i]=min
    print(flog[n-1])
   # print(flog)
if __name__=="__main__":
    main()
import math
n = int(input())

al = [chr(ord('a') + i) for i in range(26)]



ans = []
mod = 1
cnt = 0
while cnt >= 1:
    k = math.floor(n/26)
    ans.append(al[k % 26 - 1])

print(int(''.join(ans[::-1])))

### FIXED CODE ###

N = int(input())
ans = ''

while N > 0:
    N -= 1
    ans += chr(ord('a') + N % 26)
    N //= 26

print(ans[::-1])