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

num_of_S = int(input())
S = list(map(int, input().split(' ')))
num_of_T = int(input())
T = list(map(int, input().split(' ')))

count = 0
for s in S:
    for i in range(len(T)):
        if s == T[i]:
            count += 1
            T[i] = -1
            break

print(count)

### FIXED CODE ###

# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_B&lang=jp
sample_input = list(range(3))
sample_input[0] = '''5
1 2 3 4 5
3
3 4 1'''
sample_input[1] = '''3
1 2 3
1
5'''
sample_input[2] = ''''''
give_sample_input = None
if give_sample_input is not None:
    sample_input_list = sample_input[give_sample_input].split('\n')
    def input():
        return sample_input_list.pop(0)
        
# main
num_of_S = int(input())
S = list(map(int, input().split(' ')))
num_of_T = int(input())
T = list(map(int, input().split(' ')))

def binary_search(increasing_list, elem):
    index_min = 0
    index_max = num_of_S-1
    
    while index_max - index_min >= 2:
        index_middle = int((index_min + index_max) / 2)
        if increasing_list[index_middle] == elem:
            return True
        elif increasing_list[index_middle] > elem:
            index_max = index_middle
        else:
            index_min = index_middle
            
    if increasing_list[index_min] == elem:
        return True
    elif increasing_list[index_max] == elem:
        return True
    else:
        return False

count = 0
for t in T:
    if binary_search(S, t):
        count += 1
print(count)
### BUGGY CODE ###

N = int(input())

s = input().split(" ")

judge = False

for i in range(N):

  for j in range(i+1,N):
    if s[i] == s[j]:
      judge = True
      break

  if judge == True:
    break

if judge == True:
  print("NO")
else:
  print("YES")







### FIXED CODE ###

N = int(input())

s = input().split(" ")

b = len(s)

s = set(s)

a = len(s)



if a == b:
  print("YES")
else:
  print("NO")
### BUGGY CODE ###

def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

N,W = MAP()
weight=[]
value=[]
for i in range(N):
    w,v = MAP()
    weight.append(w)
    value.append(v)
MAX_V = 100100

dp = [[MOD]*(MAX_V+1) for _ in range(N+1)]
dp[0][0]=0

for i in range(N):
    for sum_v in range(MAX_V):
        if sum_v - value[i]>=0:
            dp[i+1][sum_v] = min(dp[i+1][sum_v],dp[i][sum_v-value[i]]+weight[i])
        dp[i+1][sum_v] = min(dp[i+1][sum_v],dp[i][sum_v])


for sum_v in range(MAX_V):
    if dp[N][sum_v]<=W:
        res=sum_v
print(res)

### FIXED CODE ###

def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

N,W = MAP()
weight=[]
value=[]
for i in range(N):
    w,v = MAP()
    weight.append(w)
    value.append(v)
MAX_V = 100100

dp = [[MOD]*(MAX_V+1) for _ in range(N+1)]
dp[0][0]=0

for i in range(N):
    for sum_v in range(MAX_V):
        if sum_v - value[i]>=0:
            dp[i+1][sum_v] = min(dp[i+1][sum_v],dp[i][sum_v-value[i]]+weight[i])
        dp[i+1][sum_v] = min(dp[i+1][sum_v],dp[i][sum_v])


for sum_v in range(MAX_V):
    if dp[N][sum_v]<=W:
        res=sum_v
print(res)
### BUGGY CODE ###

n,m = map(int,input().split())
# A_2=0
# B_2=0
list_A=[]
list_B=[]
sum_num=0
for i in range(n):
    A,B = map(int,input().split())
    list_A.append(A)
    list_B.append(B)

for i in range(n):
    minj = i
    for j in range(i,n):
        if list_A[j]<list_A[minj]:
            minj=j
    hokan=list_A[i]
    list_A[i]=list_A[minj]
    list_A[minj]=hokan
    hokan_b=list_B[i]
    list_B[i]=list_B[minj]
    list_B[minj]=hokan_b

list_AB = []
for i in range(n):
    list_AB.append( (list_A[i], list_B[i]))

list_AB.sort()
list_A , list_B = zip(*list_AB)
# list_A.sort()
# list_B.sort()
# print(list_A)
# print(list_B)


m_1=m
for i in range(n):
    m_2=m_1
    m_1=m_1-int(list_B[i])
    if m_1<0:
        sum_num=sum_num + int(list_A[i])*m_2
    else:
        sum_num=sum_num +int(list_A[i])*int(list_B[i])
    #print(sum_num)
    #print("m_1",m_1,"m_2",m_2)
    if m_1<0:
        break

print(sum_num)


### FIXED CODE ###

n,m = map(int,input().split())
# A_2=0
# B_2=0
list_A=[]
list_B=[]
sum_num=0
for i in range(n):
    A,B = map(int,input().split())
    list_A.append(A)
    list_B.append(B)


list_AB = []
for i in range(n):
    list_AB.append( (list_A[i], list_B[i]))

list_AB.sort()
list_A , list_B = zip(*list_AB)
# list_A.sort()
# list_B.sort()
# print(list_A)
# print(list_B)


m_1=m
for i in range(n):
    m_2=m_1
    m_1=m_1-int(list_B[i])
    if m_1<0:
        sum_num=sum_num + int(list_A[i])*m_2
    else:
        sum_num=sum_num +int(list_A[i])*int(list_B[i])
    #print(sum_num)
    #print("m_1",m_1,"m_2",m_2)
    if m_1<0:
        break

print(sum_num)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n-1):
  for j in range(i+1,n):
    ans+=a[i]*a[j]
  
print(ans%(10**9+7))

### FIXED CODE ###

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

N, T = map(int, input().split())
a = [int(i) for i in input().split()]
d = [max(a[i:]) - a[i] for i in range(N-1)]
ans = d.count(max(d))
print(ans)

### FIXED CODE ###

N, T = map(int, input().split())
a = [int(i) for i in input().split()]
b = [a[0]]
m = b[0]
for i in range(1,N):
	if m > a[i]:
		m = a[i]
	b.append(m)
c = [a[i] - b[i] for i in range(N)]
print(c.count(max(c)))
### BUGGY CODE ###

def mitsui2019d_lucky_pin():
    import itertools
    n = int(input())
    s = input()
    cnt = 0
    for t in itertools.product(range(0, 10), repeat=3):
        si = ''.join(map(str,t))
        for i in range(n - 2):
            if si[0] != s[i]: continue
            for j in range(i + 1, n - 1):
                if si[1] != s[j]: continue
                if si[2] in s[j + 1:]:
                    cnt += 1
                    break
            break
    print(cnt)


mitsui2019d_lucky_pin()

### FIXED CODE ###

def mitsui2019d_lucky_pin():
    import itertools
    n = int(input())
    s = input()
    cnt = 0
    for t in itertools.product(range(0, 10), repeat=2):
        si = ''.join(map(str,t))
        for i in range(n - 2):
            if si[0] != s[i]: continue
            for j in range(i + 1, n - 1):
                if si[1] != s[j]: continue
                ss = set(list(s[j+1:]))
                cnt += len(ss)
                break
            break
    print(cnt)


mitsui2019d_lucky_pin()
### BUGGY CODE ###

s = list(input())
ans = 0
judge = True

while judge:
    count = 0
    for i in range(1,len(s)):
        if s[-i] == "W" and s[-i-1] == "B":
            ans += 1
            s[-i] = "B"
            s[-i-1] = "W"
            count += 1
    if count == 0:
        judge =False
print(ans)

### FIXED CODE ###

s = list(input())
ans = 0
count = 0
for i in range(len(s)):
    if s[i] == "B":
        count += 1
    if s[i] == "W":
        ans += count
print(ans)
### BUGGY CODE ###

n, a, b = map(int,input().split())
t = pow(2, n, 10**9 + 7) - 1
x = 1
y = 1
for i in range(a):
    x *= (n - i)
    y *= (a - i)
f = (x // y) % (10**9 + 7)
x = 1
y = 1
for i in range(b):
    x *= (n - i)
    y *= (b - i)
s = (x // y) % (10**9 + 7)

print((t - f - s + (10**9 + 7)) % (10**9 + 7))


### FIXED CODE ###

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

def inv(a):
    return pow(a, (10**9 + 7) - 2, (10**9 + 7))
    
    
t = pow(2, n, 10**9 + 7) - 1
x = 1
y = 1
for i in range(a):
    x *= (n - i)
    x %= (10**9 + 7)
    y *= (a - i)
    y %= (10**9 + 7)
    
f = (x * inv(y)) % (10**9 + 7)
x = 1
y = 1

for i in range(b):
    x *= (n - i)
    x %= (10**9 + 7)
    y *= (b - i)
    y %= (10**9 + 7)
s = (x * inv(y)) % (10**9 + 7)

print((t - f - s + (10**9 + 7)) % (10**9 + 7))
### BUGGY CODE ###

def main():
    n = int(input())
    a = list(map(int, input().split()))
    x, y = a[0], a[1]
    nim = 0
    for i in range(2, n):
        nim ^= a[i]
    ans = 0

    while((x ^ y) != nim):
        for i in range(50, -1, -1):
            j = (nim >> i) & 1
            xy = ((x >> i) ^ (y >> i)) & 1
            if j != xy:
                m = min(x % (2**i)+1, 2**i-(y % (2**i)))
                if x % (2**i)+1 == 2**i-(y % (2**i)):
                    print(-1)
                    return
                x -= m
                y += m
                ans += m
                break
        if x == 0:
            print(-1)
            return
    print(ans)


main()


### FIXED CODE ###

def main():
    n = int(input())
    a = list(map(int, input().split()))
    x, y = a[0], a[1]
    nim = 0
    for i in range(2, n):
        nim ^= a[i]
    ans = 0

    while((x ^ y) != nim):
        for i in range(50, -1, -1):
            j = (nim >> i) & 1
            xy = ((x >> i) ^ (y >> i)) & 1
            if j != xy:
                m = min(x % (2**i)+1, 2**i-(y % (2**i)))
                if x % (2**i)+1 == 2**i-(y % (2**i)):
                    print(-1)
                    return
                x -= m
                y += m
                ans += m
                if x <= 0:
                    print(-1)
                    return
                break
        else:
            if (x ^ y) != nim:
                print(-1)
                return
    print(ans)


main()
### BUGGY CODE ###

n=int(input())
c=input()
wlist=[]
rlist=[]
for i in range(n):
  if c[i]=='R':
    rlist.append(i)
  else:
    wlist.append(i)
rlist.sort(reverse=True)
cnt=0
for j in range(n):
  if rlist==[] or wlist==[]:
    break
  if rlist[0]>wlist[0]:
    cnt+=1
    rlist.remove(rlist[0])
    wlist.remove(wlist[0])
print(cnt)

### FIXED CODE ###

n=int(input())
c=input()
wlist=[]
rlist=[]
cntw=0
cntr=0
for i in range(n):
  if c[i]=='R':
    rlist.append(i)
    cntr+=1
  else:
    wlist.append(i)
    cntw+=1
rlist.sort(reverse=True)
cnt=0
for j in range(min(cntw,cntr)):
  if rlist==[] or wlist==[]:
    break
  elif rlist[j]>wlist[j]:
    cnt+=1
print(cnt)
### BUGGY CODE ###

import itertools

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

for i in itertools.combinations(A,2):
    if i[0]==i[1]:
        print("NO")
        break
else:
    print("YES")

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort()
for i in range(N-1):
    if A[i] == A[i+1]:
        print("NO")
        break
else:
    print("YES")
### BUGGY CODE ###

from collections import deque

N,K=map(int,input().split())
if N==1:print(K)
else:
  G=[[] for i in range(N+1)]
  #deg=[0]*(N+1)
  mod=10**9+7

  for i in range(N-1):
    a,b=map(int,input().split())
    G[a].append(b)
    G[b].append(a)
    #deg[a]+=1
    #deg[b]+=1

  #deg2 = sorted(enumerate(deg),key=lambda x:x[1])
  for i in range(1,N+1):
    if len(G[i])==1:break
  first = i
  #first = deg2[1][0]
  second = G[first][0]
  color = [1]*(N+1)
  color[first],color[second]=K,K-1

  def bfs(s):
      seen = [0]*(N+1)
      todo = deque([])
      seen[s]=1
      todo.append(s)
      while 1:
        if len(todo)==0:break
        a = todo.popleft()
        if a != first: 
          acolor=K-1
        for b in G[a]:
          if seen[b] == 0:
            seen[b] = 1
            todo.append(b)
            if b != second:
              acolor -= 1
              color[b] = acolor

  bfs(first)
  total=1
  for i in range(1,N+1):
    total *= color[i]
  total %= mod
  print(total)

### FIXED CODE ###

from collections import deque

N,K=map(int,input().split())
mod = 10**9+7
G=[[] for _ in range(N)]
for i in range(N-1):
  a,b=map(int,input().split())
  G[a-1].append(b-1)
  G[b-1].append(a-1)

def bfs(s):
    seen = [0]*N
    prev = [0]*N
    color = [0]*N
    todo = deque()
    seen[s]=1
    todo.append(s)
    color[s]=K
    while todo:
      a = todo.popleft()
      if a == start: count = K-1
      else: count = K-2
      for b in G[a]:
        if seen[b] == 0:
          seen[b] = 1
          todo.append(b)
          prev[b] = a
          color[b] = count %mod
          count -= 1
    return color
  
MAX,start = 0,-1
for i in range(N):
  if len(G[i])>MAX:
    MAX=len(G[i])
    start = i
    
color = bfs(start)
ans = 1
for i in range(N):
  ans *= color[i]
  ans %= mod
  
print(ans)
### BUGGY CODE ###

from collections import deque
N = int(input())

d = deque([0])
table = [-1]*(N+1)
table[0] = 0
while d:
    i = d.popleft()
    j = 6
    k = 9
    if (i < N):
        if table[i+1] == -1:
            table[i+1] = table[i] + 1
        else:
            table[i+1] = min(table[i+1], table[i] + 1)
        d.append(i+1)

    while i + j <= N:
        if table[i+j] == -1:
            table[i+j] = table[i] + 1
            d.append(j)
        else:
            table[i+j] = min(table[i]+1, table[i+j])
        j *= 6
    while i + k <= N:
        if table[i+k] == -1:
            table[i+k] = table[i] + 1
            d.append(k)
        else:
            table[i+k] = min(table[i]+1, table[i+k])
        k *= 9
print(table[N])            

### FIXED CODE ###

N = int(input())
dp = [0] * (N+1)
for i in range(1,N+1):
    dp[i] = float('inf')
    power = 1
    while power <= i:
        dp[i] = min(dp[i], dp[i-power] +1)
        power *= 6
    power = 9
    while power <= i:
        dp[i] = min(dp[i], dp[i-power] + 1)
        power *= 9
print(dp[N])
### BUGGY CODE ###

#!/usr/bin/env python3
import sys

def E(N):
    SUM = N*(N+1)/2
    return SUM / N

def solve(N: int, K: int, p: "List[int]"):
    P = [E(val) for val in p]

    memo = []
    for n in range(N):
        group = P[n:n+K]
        memo.append(sum(group))

    print(max(memo))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

def E(N):
    SUM = N*(N+1)/2
    return SUM / N

def solve(N: int, K: int, p: "List[int]"):
    P = [E(val) for val in p]

    group_sum = sum(P[:K])
    memo = [group_sum]

    for n in range(N-K):
        group_sum = group_sum - P[n] + P[n+K]
        memo.append(group_sum)

    print(max(memo))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)

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

import sys
input = sys.stdin.readline
from numba import njit
import numpy


def read():
    N = int(input().strip())
    line = input().strip()
    P = numpy.fromstring(line, dtype=numpy.int32, sep=" ")
    return N, P


@njit
def dfs(N, Q, stay, y, x, q):
    for dy, dx in ((0, 1), (1, 0), (-1, 0), (0, -1)):
        ny, nx = y + dy, x + dx
        if 0 <= ny < N and 0 <= nx < N:
            if Q[ny, nx] > q:
                Q[ny, nx] = q
                dfs(N, Q, stay, ny, nx, q + stay[ny, nx])


@njit
def np_solve(N, P, INF=10**9):
    P -= 1
    Q = numpy.empty((N, N), dtype=numpy.int32)
    stay = numpy.ones((N, N), dtype=numpy.bool_)
    
    for r in range(N//2+1):
        Q[r:N-r, r:N-r] = r

    ans = 0
    for p in P:
        y, x = divmod(p, N)
        stay[y, x] = 0
        q = Q[y, x]
        ans += q
        dfs(N, Q, stay, y, x, q)
    return ans


if __name__ == '__main__':
    outputs = np_solve(*read())
    if outputs is not None:
        print("{}".format(outputs))


### FIXED CODE ###

import sys
input = sys.stdin.readline
from numba import njit
import numpy


def read():
    N = int(input().strip())
    line = input().strip()
    P = numpy.fromstring(line, dtype=numpy.int32, sep=" ")
    return N, P


@njit
def dfs(N, Q, stay, p, q):
    y, x = divmod(p, N)
    for dy, dx in ((0, 1), (1, 0), (-1, 0), (0, -1)):
        ny, nx = y + dy, x + dx
        if 0 <= ny < N and 0 <= nx < N:
            np = ny * N + nx
            if Q[np] > q:
                Q[np] = q
                dfs(N, Q, stay, np, q + stay[np])


@njit
def np_solve(N, P, INF=10**9):
    P -= 1
    Q = numpy.empty(N*N, dtype=numpy.int32)
    stay = numpy.ones(N*N, dtype=numpy.bool_)
    
    for i in range(N):
        for j in range(N):
            Q[i*N+j] = min([i, j, N-i-1, N-j-1])

    ans = 0
    for p in P:
        stay[p] = 0
        q = Q[p]
        ans += q
        dfs(N, Q, stay, p, q)
    return ans


if __name__ == '__main__':
    outputs = np_solve(*read())
    if outputs is not None:
        print("{}".format(outputs))
### BUGGY CODE ###

from itertools import combinations
n = int(input())
s = [sorted(list(input())) for _ in range(n)]
ans = 0
for v in combinations(s, 2):
    if v[0] == v[1]:
        ans += 1

print(ans)

### FIXED CODE ###

n = int(input())
s = []
for _ in range(n):
    s.append(input())


cnt = 0
tmpdic = {}
for i in s:
    tmp = "".join(sorted(i))
    if tmp in tmpdic.keys():
        cnt += tmpdic[tmp]
        tmpdic[tmp] += 1
    else:
        tmpdic[tmp] = 1


print(cnt)
### BUGGY CODE ###

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

cnt = 0
for i in range(len(lst)):
    num = lst[i]
    if num == min(lst[:i+1]):
        cnt += 1

print(cnt)


### FIXED CODE ###

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

cnt = 0
tmp_min = max(lst)
for i in range(len(lst)):
    num = lst[i]
    if num <= tmp_min:
        cnt += 1
        tmp_min = num

print(cnt)
### BUGGY CODE ###

n,x,y = map(int,input().split())
x,y=x-1,y-1

dist = [0]*5000

for i in range(n):
    for j in range(i+1,n):
        tmp = j - i
        tmp = min(tmp,abs(i-x) + abs(y-j)+1)
        tmp = min(tmp,abs(i-y) + abs(x-j)+1)
        dist[tmp] +=1

for i in range(1,n):
    print(dist[i])

### FIXED CODE ###

n,x,y = map(int,input().split())
x,y=x-1,y-1

dist = [0]*5000

for i in range(n):
    for j in range(i+1,n):
        tmp = j - i
        tmp = min(tmp,abs(i-x) + abs(y-j)+1)
        tmp = min(tmp,abs(i-y) + abs(x-j)+1)
        dist[tmp] +=1

for i in range(1,n):
    print(dist[i])
### BUGGY CODE ###

a = int(input())

sum = 0
for i in range(a):
    sum += i
print(sum)

### FIXED CODE ###

from decimal import *
a = int(input())

print(int(Decimal((a -1)/2)*Decimal(a)))
### BUGGY CODE ###

#https://atcoder.jp/contests/dp/tasks/dp_d
N,W = map(int,input().split())
Goods_List=[]
for i in range(N):
    Goods_List.append(list(map(int,input().split())))
 
Sum_Weight = sum(map(lambda x:x[0],Goods_List))
dp = [[-1] * (W + 1) for i in range(N)]
 
for i in range(N):
    Current_Weight = Goods_List[i][0]
    Current_Value  = Goods_List[i][1]
    dp[i][0] = 0
    if (i == 0) & (Current_Weight <= W) :
        dp[i][Current_Weight] = Current_Value
    elif i > 0:
        Last_Search_List = [j for j, x in enumerate(dp[i-1]) if x > -1]
        Current_Search_List = list(map(lambda x:x+Current_Weight,Last_Search_List))
        ##まずは前回値を入れる
        for l in range(len(Last_Search_List)):
            Last_Search_Weight =  Last_Search_List[l] 
            dp[i][Last_Search_Weight] = dp[i-1][Last_Search_Weight]
        ##今回値と比べる
        for k in range(len(Current_Search_List)):
            Last_Search_Weight =  Last_Search_List[k] 
            Current_Search_Weight = Current_Search_List[k]
            if Current_Search_Weight > W:
                break
            else:
                dp[i][Current_Search_Weight] = max((dp[i-1][Last_Search_Weight] + Current_Value),
                                                   dp[i-1][Current_Search_Weight])
 
 
print(max(dp[N-1]))

### FIXED CODE ###

#https://atcoder.jp/contests/dp/tasks/dp_d
N,W = map(int,input().split())
Goods_List=[]
for i in range(N):
    Goods_List.append(list(map(int,input().split())))

Sum_Weight = sum(map(lambda x:x[0],Goods_List))
dp = [[-1] * (W + 1) for i in range(N)]

for i in range(N):
    Current_Weight = Goods_List[i][0]
    Current_Value  = Goods_List[i][1]
    dp[i][0] = 0
    if (i == 0) & (Current_Weight <= W) :
        dp[i][Current_Weight] = Current_Value
    elif i > 0:
        Last_Search_List = [j for j, x in enumerate(dp[i-1]) if x > -1]
        Current_Search_List = list(map(lambda x:x+Current_Weight,Last_Search_List))
        ##まずは前回値を入れる
        for l in range(len(Last_Search_List)):
            Last_Search_Weight =  Last_Search_List[l] 
            dp[i][Last_Search_Weight] = dp[i-1][Last_Search_Weight]
        ##今回値と比べる
        for k in range(len(Current_Search_List)):
            Last_Search_Weight =  Last_Search_List[k] 
            Current_Search_Weight = Current_Search_List[k]
            if Current_Search_Weight > W:
                break
            else:
                dp[i][Current_Search_Weight] = max((dp[i-1][Last_Search_Weight] + Current_Value),
                                                   dp[i-1][Current_Search_Weight])


print(max(dp[N-1]))
### BUGGY 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)

n,k,l = map(int,input().split())
Road = [list(map(int,input().split())) for i in range(k)]
Train = [list(map(int,input().split())) for i in range(l)]

uf_r = UnionFind(n)
uf_t = UnionFind(n)
uf = UnionFind(n)

for i in range(k):
    uf_r.union(Road[i][0]-1,Road[i][1]-1)

for i in range(l):
    uf_t.union(Train[i][0]-1,Train[i][1]-1)

Roots = [[0]*n for i in range(n)]

for i in range(n):
    Roots[uf_r.find(i)][uf_t.find(i)] += 1

ans = [0]*n

for i in range(n):
    ans[i] = Roots[uf_r.find(i)][uf_t.find(i)]

print(*ans)

### FIXED CODE ###

import sys
from collections import defaultdict
input = sys.stdin.readline

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 roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

def main():
    n,k,l = map(int,input().split())
    Road = [list(map(int,input().split())) for i in range(k)]
    Train = [list(map(int,input().split())) for i in range(l)]

    uf_r = UnionFind(n)
    uf_t = UnionFind(n)

    for i in range(k):
        uf_r.union(Road[i][0]-1,Road[i][1]-1)

    for i in range(l):
        uf_t.union(Train[i][0]-1,Train[i][1]-1)

    Roots_dict = defaultdict(int)
    Roots = []
    for i in range(n):
        Roots.append(str(uf_r.find(i))+' '+str(uf_t.find(i)))
        Roots_dict[Roots[i]] += 1

    ans = [0]*n

    for i in range(n):
        ans[i] = Roots_dict[Roots[i]]

    print(*ans)

if __name__ == '__main__':
    main()