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

N = int(input())
A = input().split()
A = [int(s) for s in A]

sum = 1
i = 0
while i < len(A):
    if 0 in A:
        sum = 0
        break
    sum *= A[i]
    i+=1
    if sum > 1000000000000000000:
      break

if sum > 1000000000000000000:
    sum = -1

print(sum)

### FIXED CODE ###

N = int(input())
A = input().split()
A = [int(s) for s in A]

sum = 1

if 0 in A:
    sum = 0

else:
    for i in range(len(A)):
        sum *= A[i]
        if sum > 1000000000000000000:
            break
    
if sum > 1000000000000000000:
    sum = -1

print(sum)
### BUGGY CODE ###

import numpy as np
n,k=map(int,input().split())
a=list(map(int,input().split()))
A=np.array(a)
l,r=0,0
for i in range(min(41,k)):
    B=np.zeros(n,dtype=np.int64)
    for x,y in enumerate(list(A)):
        l=max(0,x-y)
        r=min(n-1,x+y)
        B[l:r+1]+=1
    A=B
print(*A,sep=' ')

### FIXED CODE ###

import numpy as np
from numba import jit
@jit(cache = True)
def solve(n,k,A):
    l,r=0,0
    for i in range(k):
        B=np.zeros(n+1,dtype=np.int64)
        for x,y in enumerate(list(A)):
            l=max(0,x-y)
            r=min(n,x+y+1)
            B[l]+=1
            B[r]-=1
        A=np.cumsum(B[:-1])
        if A[A==n].size==n:
            break
    return A
n,k=map(int,input().split())
a=list(map(int,input().split()))
A=np.array(a)
X=solve(n,k,A)
print(*X,sep=' ')
### BUGGY CODE ###

def main():
    s=input()
    l = len(s)
    while "01" in s or "10" in s:
        s = s.replace("01", "").replace("10", "")
    print((l-len(s)))
        
if __name__ == "__main__":
    main()

### FIXED CODE ###

s=input()
zero = s.count("0")
one = s.count("1")
print(len(s)-abs(zero-one))
### BUGGY CODE ###

import math
pi = math.acos(-1)
N, L = map(int, input().split())
NN = N * (N-1) * (N-2) // 6
T = [int(input()) for _ in range(N)]
print(sum([sum([math.cos((T[i]+T[j])*pi/L) * (N+2*(i-j)) for j in range(i+1, N)]) for i in range(N)])/NN, sum([sum([math.sin((T[i]+T[j])*pi/L) * (N+2*(i-j)) for j in range(i+1, N)]) for i in range(N)])/NN)

### FIXED CODE ###

import math
pi = math.acos(-1)
N, L = map(int, input().split())
NN = N * (N-1) * (N-2) // 6
T = [int(input()) for _ in range(N)]
print(sum([sum([math.cos((T[i]+T[j])*pi/L) * (N+2*(i-j)) for j in range(i+1, N)]) for i in range(N)])/NN, sum([sum([math.sin((T[i]+T[j])*pi/L) * (N+2*(i-j)) for j in range(i+1, N)]) for i in range(N)])/NN)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys

def solve(k: int, q: int, d: "List[int]", n: "List[int]", x: "List[int]", m: "List[int]"):
    for query in range(q):
        N,X,M = n[query],x[query],m[query]
        D = [d[i]%M for i in range(k)]
        COUNTD = D.count(0)
        SUMD = sum(D)
        last = 0
        if (N-1)%k == 0:
            last = X+((N-1)//k)*SUMD
            equal_count = COUNTD*((N-1)//k)
        else:
            last = X + SUMD*((N-1)//k) + sum(D[:(N-1)%k])
            equal_count = COUNTD*((N-1)//k)+D[:(N-1)%k].count(0)
        
        shounari_count = last//M - X//M
        dainari_count = N-shounari_count-equal_count-1
        print(dainari_count)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    k = int(next(tokens))  # type: int
    q = int(next(tokens))  # type: int
    d = [int(next(tokens)) for _ in range(k - 1 - 0 + 1)]  # type: "List[int]"
    n = [int()] * (q)  # type: "List[int]"
    x = [int()] * (q)  # type: "List[int]"
    m = [int()] * (q)  # type: "List[int]"
    for i in range(q):
        n[i] = int(next(tokens))
        x[i] = int(next(tokens))
        m[i] = int(next(tokens))
    solve(k, q, d, n, x, m)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from itertools import accumulate
def solve(k: int, q: int, d: "List[int]", n: "List[int]", x: "List[int]", m: "List[int]"):
    for query in range(q):
        N,X,M = n[query],x[query],m[query]
        count = [0]*k
        D = [0]*k
        c = 0
        for i in range(k):
            D[i] = d[i]%M
            if D[i] == 0:
                c += 1
            count[i] = c
        accum = list(accumulate(D))
        SUMD = accum[-1]
        COUNTD = count[-1]

        if (N-1)%k == 0:
            last = X+((N-1)//k)*SUMD
            equal_count = COUNTD*((N-1)//k)
        else:
            last = X + SUMD*((N-1)//k) + accum[(N-1)%k-1]
            equal_count = COUNTD*((N-1)//k)+count[(N-1)%k-1]
        
        shounari_count = last//M - X//M
        dainari_count = N-shounari_count-equal_count-1
        print(dainari_count)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    k = int(next(tokens))  # type: int
    q = int(next(tokens))  # type: int
    d = [int(next(tokens)) for _ in range(k - 1 - 0 + 1)]  # type: "List[int]"
    n = [int()] * (q)  # type: "List[int]"
    x = [int()] * (q)  # type: "List[int]"
    m = [int()] * (q)  # type: "List[int]"
    for i in range(q):
        n[i] = int(next(tokens))
        x[i] = int(next(tokens))
        m[i] = int(next(tokens))
    solve(k, q, d, n, x, m)

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

n,m = map(int,input().split())
ab = {i:[] for i in range(m+1)}
for i in range(n):
    a,b = map(int,input().split())
    if a in ab:
        ab[a].append(b)
    else:
        ab[a] = [b]
#print(ab)
ans = 0
for i in range(m)[::-1]:
    rem = m - i
    if ab[rem]:
        job = ab[rem]
        ans += max(job)
        del ab[rem][job.index(max(job))]
        if rem < m:
            ab[rem+1] += ab[rem]
            ab[rem] = []
    #print(ans)
print(ans)


### FIXED CODE ###

from heapq import *
n,m = map(int,input().split())
t = [[] for i in range(10**5+1)]
for i in range(n):
    a,b = map(int,input().split())
    t[a].append(b)

ans = 0
h = []
for i in range(1,m+1):
    #print(i,"日目")
    for j in t[i]:
        heappush(h, -j)
        #print("heappush",j)
    if h:
        a = -heappop(h)
        #print("heappop",a)
        ans += a
print(ans)
### BUGGY CODE ###

from collections import Counter

def Comb(n,k):
    comb_ans=1
    for i in range(1,k+1):
        comb_ans*=(n-i+1)/i
    comb_ans=int(comb_ans)
    return comb_ans

N=int(input())
A=list(map(int,input().split()))
C=Counter()
C.update(A)
ans=0
L=[0]*N
for i in range(N):
    L[A[i]-1]+=1
for i in range(len(C)):
    ans+=Comb(C.most_common()[i][1],2)
for i in range(N):
    pri=ans
    pri=ans-L[A[i]-1]+1
    print(pri)

### FIXED CODE ###

from collections import Counter

def Comb(n,k):
    comb_ans=1
    for i in range(1,k+1):
        comb_ans*=(n-i+1)/i
    comb_ans=int(comb_ans)
    return comb_ans

N=int(input())
A=list(map(int,input().split()))
C=Counter()
C.update(A)
ans=0
L=[0]*N
for i in range(N):
    L[A[i]-1]+=1
Most=C.most_common()
#print(Most)
for i in range(len(C)):
    ans+=Comb(Most[i][1],2)
for i in range(N):
    pri=ans
    pri=ans-L[A[i]-1]+1
    print(pri)
### BUGGY CODE ###

from itertools import combinations

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

c = combinations(L, 3)
ans = 0
for v in c:
    a, b, c = v
    if (a < b + c) and (b < a + c) and (c < a + b): ans += 1
print(ans)

### FIXED CODE ###

import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-1, 1, -1):
    for j in range(i-1, 0, -1):
        a, b = L[i], L[j]
        c = a - b + 1
        if c > b: continue
        ans += (j - bisect.bisect_left(L, c))
print(ans)
### BUGGY CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
a = sorted(inpl(), reverse = True)
b = [0,2,5,5,4,5,6,3,7,6]
dp = [[0]*(n+1) for _ in range(m+1)]

for i,x in enumerate(a):
    for c in range(b[x],n+1,b[x]):
        va = x * (c//b[x])
        # print(c,va)
        for j in range(n+1):
            if j != 0 and (j % c == 0 or (j >= c and dp[i+1][j-c] != 0)):
                dp[i+1][j] = max(dp[i][j],dp[i+1][j], dp[i+1][j-c]*10 + va)
                continue
            dp[i+1][j] = max(dp[i+1][j], dp[i][j])
print(dp[-1][-1])

### FIXED CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
a = sorted(inpl(), reverse = True)
b = [0,2,5,5,4,5,6,3,7,6]
dp = [0] * (n+1)

for i in a:
    w,v = b[i],i
    for j in range(n+1):
        if j < w:
            continue
        if j%w == 0 or dp[j-w]:
            dp[j] = max(dp[j], dp[j-w]*10 + v)
    # print(dp)
print(dp[-1])
### BUGGY CODE ###

# D Knapsack 1

from collections import deque

n, w = map(int,input().split())
wv_list = deque([[int(x) for x in input().split()] for y in range(n)])

dp = [[float("-Inf")] * (w+1) for _ in range(n+1)]
dp[0] = [0]*(w+1)

for i in range(n):
    _w,_v = wv_list.popleft()
    for j in range(w+1):
        if j-_w < 0:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i][j-_w]+_v)

print(dp[n][w])

### FIXED CODE ###

# D Knapsack 1

from collections import deque

n, w = map(int,input().split())
wv_list = deque([[int(x) for x in input().split()] for y in range(n)])

dp = [[float("-Inf")] * (w+1) for _ in range(n+1)]
dp[0] = [0]*(w+1)

for i in range(n):
    _w,_v = wv_list.popleft()
    for j in range(w+1):
        if j-_w < 0:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i][j-_w]+_v)

print(dp[n][w])
### BUGGY CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())

def main():
    mod = 10**9+7
    n = ii()
    a = li()
    bi = [0]*60
    for x in a:
        for i in range(60):
            if (x>>i)&1:
                bi[i]+= 1
    ans = 0
    for i in range(60):
        tmp = bi[i]*(n-bi[i])*(1<<i)
        tmp %= mod
        ans += tmp
        ans %= mod

    print(ans)



if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())

def main():
    mod = 10**9+7
    n = ii()
    a = li()
    bi = [0]*60
    for x in a:
        for i in range(60):
            if (x>>i)&1:
                bi[i]+= 1
    ans = 0
    for i in range(60):
        tmp = bi[i]*(n-bi[i])*(1<<i)
        tmp %= mod
        ans += tmp
        ans %= mod

    print(ans)



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

N, M = map(int, input().split())
m = 0b0
exec("m = 0b" + "1"*N)
for i in range(M):
	L, R = map(int, input().split())
	exec("_m = 0b" + "1"*(R - L + 1) + "0"*(N - R))
	m = m & _m
	if m == 0b0 : break

print(bin(m).count("1"))


### FIXED CODE ###

N, M = map(int, input().split())
L, R = 0, N
for i in range(M):
	_L, _R = map(int, input().split())
	L = max(_L, L)
	R = min(_R, R)

print(max(R - L + 1, 0))
### BUGGY CODE ###

import copy

N = int(input())
A = ()
A = [input() for i in range(N)]

B = ()
for i in range(N):
    B = copy.copy(A)
    B.pop(i)
    print(max(B))


### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]

a = max(A)
b = sorted(A)[-2]
for i in A:
    print(b if i == a else a)
### BUGGY CODE ###

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

### FIXED CODE ###

import numpy as np

N = int(input())
mod = 10**9 + 7
A = np.array(input().split(), int)

ans = 0
for i in range(60):
    b = np.count_nonzero(A >> i & 1)
    ans += 2**i*(b*(N-b))
    ans %= mod
    c = np.count_nonzero(A >> i & 1)
print(ans)
### BUGGY CODE ###

K = int(input())
start = j = 7 % K
count = 1
while j != 0:
    j = 10 * j + 7
    j = j % K
    count += 1
    if j == start:
        print(-1)
        exit()
print(count)

### FIXED CODE ###

K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()

start = j = 7 % K
count = 1

#無限ループ
while True:
    #0の時
    if j == 0:
        print(count)
        exit()
        
    j = 10 * j + 7
    j = j % K
    count += 1
    
    #同じ数のループしているかチェック
    if j == start:
        print(-1)
        exit()
### BUGGY CODE ###

from itertools import repeat
s = open(0).read().rstrip()
# from sys import stdin
# s = stdin.readline().rstrip()
state = [1]*len(s)

# from collections import defaultdict

# d = defaultdict(int)
d = set()
i = 0

def transit(l, s):
    tmp = [0]*len(s)
    for i in range(len(s)):
        if s[i] == 'R':
            tmp[i+1] += l[i]
        else:
            tmp[i-1] += l[i]
    return tmp

d.add(tuple(state))

while 1:
    prev_state, state = state, transit(state, s)
    i += 1
    tup = tuple(state)
    if tup in d:
        break
    d.add(tup)

if i%2:
    state = prev_state

print(*state)

### FIXED CODE ###

s = input().rstrip() + 'X'

r_cnt = l_cnt = 0
is_r = True
begin_l = None
ans = [0] * (len(s)-1)
for i in range(len(s)):
    if is_r and s[i] == 'R':
#         print(f'{i}: R')
        r_cnt += 1
    elif not is_r and s[i] == 'L':
#         print(f'{i}: L')
        l_cnt += 1
    elif s[i] == 'L':
#         print(f'{i}: R>L')
        is_r = False
        l_cnt = 1
        begin_l = i
    else:
#         print(f'{i}: L>?')
        is_r = True
#         print(l_cnt, r_cnt)
        tot = l_cnt + r_cnt
        small = tot//2
        large = tot - small
        if r_cnt%2:
            ans[begin_l-1] = large 
            ans[begin_l] = small
        else:
            ans[begin_l-1] = small
            ans[begin_l] = large
        r_cnt = 1
        l_cnt = 0

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

N, K = map(int, input().split())
A = list(map(int, input().split()))
A1 = set(A)
AN = {}
for a in A1:
    AN[a] = A.count(a)
AN = sorted(AN.items(), key=lambda x: x[1])
ans = 0
K1 = len(A1) - K
if K1 > 0:
    for k in range(K1):
        ans += AN[k][1]
    print(ans)
else:
    print('0')


### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
A1 = set(A)
AN = {}
for a in A:
    if not a in AN:
        AN[a] = 0
    AN[a] += 1
AN = sorted(AN.items(), key=lambda x: x[1])
ans = 0
K1 = len(A1) - K
if K1 > 0:
    for k in range(K1):
        ans += AN[k][1]
    print(ans)
else:
    print('0')
### BUGGY CODE ###

r, c, k = map(int, input().split())

items = [[0] * (c + 1) for _ in range(r + 1)]
for _ in range(k):
    i, j, v = map(int, input().split())
    items[i][j] = v

# dp[i][j][m] = (i行j列時点で、i行でm個のitemを取得している時の価値の最大値)
dp = [[[0] * 4 for _ in range(c + 1)] for _ in range(r + 1)]

for i in range(1, r + 1):
    for j in range(1, c + 1):
        for m in range(4):
            dp[i][j][m] = max(dp[i][j][m], max(dp[i - 1][j]), dp[i][j - 1][m])
        for m in reversed(range(3)):
            dp[i][j][m + 1] = max(dp[i][j][m + 1], dp[i][j][m] + items[i][j])

print(dp[r][c][3])


### FIXED CODE ###

import sys


def main():
    input = sys.stdin.readline

    r, c, k = map(int, input().split())

    items = [[0] * (c + 1) for _ in range(r + 1)]
    for _ in range(k):
        i, j, v = map(int, input().split())
        items[i][j] = v

    # dp[m][i][j] = (i行j列時点で、i行でm個のitemを取得している時の価値の最大値)
    dp = [[[0] * (c + 1) for _ in range(r + 1)] for _ in range(4)]

    for i in range(1, r + 1):
        for j in range(1, c + 1):
            for m in range(4):
                dp[m][i][j] = max(dp[3][i - 1][j], dp[m][i][j - 1])
            if items[i][j] > 0:
                for m in [2, 1, 0]:
                    dp[m + 1][i][j] = max(dp[m + 1][i][j],
                                          dp[m][i][j] + items[i][j])

    print(dp[3][r][c])


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

n = int(input())
line = list(map(int,input().split()))
for i in range(n):
    l = line[:]
    l.pop(i)
    l = sorted(l)
    print(l[n//2-1])


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
y = sorted(a)
yl = y[n//2-1]
yr = y[n//2]
for i in range(n):
    print(yr if a[i] < yr else yl)
### BUGGY CODE ###

n = int(input())

lst = [-1 for i in range(n)]
print(0, flush=True)
sex0 = input()
if sex0 == 'Male':
    lst[0] = 1
    leftsex = 1
elif sex0 == 'Female':
    lst[0] = 0
    leftsex = 0
else:
    exit()

print(n-1, flush=True)
sexn_1 = input()
if sexn_1 == 'Male':
    lst[n-1] = 1
    rightsex = 1
elif sexn_1 == 'Female':
    lst[n-1] = 0
    rightsex = 0
else:
    exit()

left = 0
right = n-1
while left+1 < right:
    mid = (left+right)//2
    print(mid, flush=True)
    sexmid = input()
    if sexmid == 'Male':
        lst[mid] = 1
        midsex = 1
    elif sexmid == 'Female':
        lst[mid] = 0
        midsex = 0
    else:
        exit()
    
    if (mid-left) % 2 == midsex - leftsex:
        left = mid
    else:
        right = mid

### FIXED CODE ###

n = int(input())

lst = [-1 for i in range(n)]
print(0)
sex0 = input()
if sex0 == 'Male':
    lst[0] = 1
    leftsex = 1
elif sex0 == 'Female':
    lst[0] = 0
    leftsex = 0
else:
    exit()

print(n-1)
sexn_1 = input()
if sexn_1 == 'Male':
    lst[n-1] = 1
    rightsex = 1
elif sexn_1 == 'Female':
    lst[n-1] = 0
    rightsex = 0
else:
    exit()

left = 0
right = n-1
while left+1 < right:
    mid = (left+right)//2
    print(mid)
    sexmid = input()
    if sexmid == 'Male':
        lst[mid] = 1
        midsex = 1
    elif sexmid == 'Female':
        lst[mid] = 0
        midsex = 0
    else:
        exit()
    
    if (mid-left) % 2 == abs(midsex-leftsex):
        left = mid
        leftsex = midsex
    else:
        right = mid
        rightsex = midsex
### BUGGY CODE ###

import sys
from collections import deque
l,n=map(int,input().split())
p=n//2
q=(n+1)//2
r=(n-1)//2
tree1=[int(i) for i in sys.stdin]
reversed_tree1=[l-i for i in reversed(tree1)]
tree=deque(tree1)
reversed_tree=deque(reversed_tree1)
if n%2 == 0:
  ans= sum(tree1)*2 + l*(n-1) +tree1[p] - sum(tree1[p:])*4
  ans2= sum(reversed_tree1)*2 + l*(n-1) +reversed_tree1[p] - sum(reversed_tree1[p:])*4
  p-=1
  n-=1
  ans3= ans-tree.popleft()*2-l+tree[p]*2
  ans= max(ans,ans3)
  ans4= ans2-reversed_tree.popleft()*2-l+(reversed_tree[p])*2
  ans2= max(ans2,ans4)
else:
  ans= sum(tree1)*2 + l*(n-1) - tree1[p] - sum(tree1[q:])*4
  ans3=ans
  ans2= sum(reversed_tree1)*2 + l*(n-1) - reversed_tree1[p] - sum(reversed_tree1[q:])*4
  ans4=ans2
while len(tree)>1:
  q-=1
  r-=1
  ans_stack= ans3-tree.popleft()*2-l+tree[r]+tree[q]
  ans= max(ans_stack,ans)
  ans3=ans_stack
  p-=1
  ans_stack= ans3-tree.popleft()*2-l+tree[p]*2
  ans=max(ans_stack,ans)
  ans3=ans_stack
p=n//2
q=(n+1)//2
r=(n-1)//2
while len(reversed_tree)>1:
  q-=1
  r-=1
  ans_stack= ans4-reversed_tree.popleft()*2-l+reversed_tree[r]+reversed_tree[q]
  ans2=max(ans_stack,ans2)
  ans4=ans_stack
  p-=1
  ans_stack= ans4-reversed_tree.popleft()*2-l+reversed_tree[p]*2
  ans2=max(ans2,ans_stack)
  ans4=ans_stack
print(max(ans,ans2))

### FIXED CODE ###

import sys
from collections import deque
l,n=map(int,input().split())
c=n
tree1=[int(i) for i in sys.stdin]
reversed_tree1=[l-i for i in reversed(tree1)]
tree=deque(tree1)
reversed_tree=deque(reversed_tree1)
if n%2 == 0:
  ans= sum(tree1)*2 + l*(n-1) +tree1[n//2] - sum(tree1[n//2:])*4
  ans2= sum(reversed_tree1)*2 + l*(n-1) +reversed_tree1[n//2] - sum(reversed_tree1[n//2:])*4
  n-=1
  c-=1
  ans3= ans-tree.popleft()*2-l+tree[n//2]*2
  ans= max(ans,ans3)
  ans4= ans2-reversed_tree.popleft()*2-l+(reversed_tree[n//2])*2
  ans2= max(ans2,ans4)
else:
  ans= sum(tree1)*2 + l*(n-1) - tree1[n//2] - sum(tree1[((n//2)+1):])*4
  ans3=ans
  ans2= sum(reversed_tree1)*2 + l*(n-1) - reversed_tree1[n//2] - sum(reversed_tree1[((n//2)+1):])*4
  ans4=ans2
for i in range(n//2):
  n-=1
  ans_stack= ans3-tree.popleft()*2-l+tree[(n-1)//2]+tree[(n+1)//2]
  ans= max(ans_stack,ans)
  ans3=ans_stack
  n-=1
  ans_stack= ans3-tree.popleft()*2-l+tree[n//2]*2
  ans=max(ans_stack,ans)
  ans3=ans_stack
n=c
for i in range(n//2):
  n-=1
  ans_stack= ans4-reversed_tree.popleft()*2-l+reversed_tree[(n-1)//2]+reversed_tree[(n+1)//2]
  ans2=max(ans_stack,ans2)
  ans4=ans_stack
  n-=1
  ans_stack= ans4-reversed_tree.popleft()*2-l+reversed_tree[n//2]*2
  ans2=max(ans2,ans_stack)
  ans4=ans_stack
print(max(ans,ans2))
### BUGGY CODE ###

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


class UFT:
    def __init__(self, N):
        self.UFdata = [-1] * (N+1)
        self.rank   = [0]  * (N+1)

    def find(self,x):
        UFdata = self.UFdata
        while UFdata[x] != -1:
            x = UFdata[x]
        return x

    def unite(self,x,y):
        UFdata = self.UFdata
        rank = self.rank 
        find = self.find

        x = find(x)
        y = find(y)
        if x != y:
            if rank[x] < rank[y]:
                x,y = y,x
            if rank[x] == rank[y]:
                rank[x] += 1
            UFdata[y] = x       
            

UF1 = UFT(N)
UF2 = UFT(N)
ans = [1] * (N+1)
MAP= [ [0] * (N+1) for _ in range(N+1)]
import sys
input = sys.stdin.readline
#PQ = [ [int(j) for j in input().split()] for _ in range(K)]
#RS = [ [int(j) for j in input().split()] for _ in range(L)]

for i in range(K):
    p,q = map(int,input().split())
    UF1.unite(p,q)
for i in range(L):
    p,q = map(int,input().split())#RS[i]
    UF2.unite(p, q)
counter=[]
from collections import defaultdict
cntdic =defaultdict(int)
for i in range(1,N+1):
  counter.append(UF1.find(i)+UF2.find(i)*10**6)
  cntdic[counter[-1]]+=1 

ans = [0]*(N+1)
for i in range(1,N+1):
    ans[i] = cntdic[counter[i-1]]

del ans[0]
# print(" ".join( map(lambda x: str(x), connected_num[1:])))
print(" ".join( map(lambda x: str(x), ans)))


### FIXED CODE ###

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


class UFT:
    def __init__(self, N):
        self.UFdata = [-1] * (N+1)
        self.rank   = [0]  * (N+1)

    def find(self,x):
        UFdata = self.UFdata
        while UFdata[x] != -1:
            x = UFdata[x]
        return x

    def unite(self,x,y):
        UFdata = self.UFdata
        rank = self.rank 
        find = self.find

        x = find(x)
        y = find(y)
        if x != y:
            if rank[x] < rank[y]:
                x,y = y,x
            if rank[x] == rank[y]:
                rank[x] += 1
            UFdata[y] = x       
            

UF1 = UFT(N)
UF2 = UFT(N)
ans = [1] * (N+1)
# MAP= [ [0] * (N+1) for _ in range(N+1)]
import sys
input = sys.stdin.readline
#PQ = [ [int(j) for j in input().split()] for _ in range(K)]
#RS = [ [int(j) for j in input().split()] for _ in range(L)]

for i in range(K):
    p,q = map(int,input().split())
    UF1.unite(p,q)
for i in range(L):
    p,q = map(int,input().split())#RS[i]
    UF2.unite(p, q)
counter=[]
from collections import defaultdict
cntdic =defaultdict(int)
for i in range(1,N+1):
  counter.append(UF1.find(i)+UF2.find(i)*10**6)
  cntdic[counter[-1]]+=1 

ans = [0]*(N+1)
for i in range(1,N+1):
    ans[i] = cntdic[counter[i-1]]

del ans[0]
# print(" ".join( map(lambda x: str(x), connected_num[1:])))
print(" ".join( map(lambda x: str(x), ans)))