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

n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
for k in range(60):
  t=1<<k
  z=o=0
  for i in a:
    if i&t:o+=1
    else:z+=1
  ans=(ans+(z*o*t))%mod
print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
x=1
for i in range(60):
  z=o=0
  for j in range(n):
    if a[j]%2:o+=1
    else:z+=1
    a[j]//=2
  ans+=(x*o*z)%mod
  ans%=mod
  x=(x*2)%mod
print(ans)
### BUGGY CODE ###

import sys
finput=lambda:sys.stdin.readline().strip()

def main():
    p=10**9+7
    n=int(finput())
    a=list(map(int,finput().split()))
    k=sum(a)-(n*(n+1))//2
    pk=[i for i in range(n+1) if a[i]==k]
    fact=[1]*(n+2)
    ifact=[1]*(n+2)
    for i in range(1,n+2):
        fact[i]=fact[i-1]*i % p
    a=fact[-1]
    inv=1
    m=p-2
    while m>0:
        if m&1:
            inv=a*inv % p
        m>>=1
        a=a*a % p
    ifact[-1]=inv
    for i in range(n+1,0,-1):
        ifact[i-1]=ifact[i]*i
    sn=pk[0]+n-pk[1]
    for i in range(1,n+2):
        if sn>=i-1:
            print(fact[n+1]*ifact[n+1-i]*ifact[i] % p - \
                  fact[sn]*ifact[sn-i+1]*ifact[i-1] % p)
        else:
            print(fact[n+1]*ifact[n+1-i]*ifact[i] % p)

if __name__=='__main__':
    main()

### FIXED CODE ###

import sys
finput=lambda:sys.stdin.readline().strip()

def main():
    p=10**9+7
    n=int(finput())
    a=list(map(int,finput().split()))
    k=sum(a)-(n*(n+1))//2
    pk=[i for i in range(n+1) if a[i]==k]
    fact=[1]*(n+2)
    ifact=[1]*(n+2)
    for i in range(1,n+2):
        fact[i]=fact[i-1]*i % p
    a=fact[-1]
    inv=1
    m=p-2
    while m>0:
        if m&1:
            inv=a*inv % p
        m>>=1
        a=a*a % p
    ifact[-1]=inv
    for i in range(n+1,0,-1):
        ifact[i-1]=ifact[i]*i % p
    ans0=[0]*(n+2)
    ans1=[0]*(n+2)
    ans2=[0]*(n+2)
    for i in range(n):
        ans0[i]=fact[n-1]*ifact[n-i-1]*ifact[i]%p
        ans1[i+1]=ans0[i]*2
        ans2[i+2]=ans0[i]
    sn=pk[0]+n-pk[1]
    for i in range(sn+1):
        ans1[i+1]-=fact[sn]*ifact[sn-i]*ifact[i] % p
    for i in range(1,n+2):
        print((ans0[i]+ans1[i]+ans2[i]) % p)

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

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

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

for i in range(N):
    for j in range(W + 1):
        if j + wv[i][0] <= W:
            dp[i + 1][j + wv[i][0]] = max(dp[i][j] + wv[i][1], dp[i][j + wv[i][0]])
        
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])

print(dp[N][W])


### FIXED CODE ###

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

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

for i in range(N):
    for j in range(W + 1):
        if j + wv[i][0] <= W:
            dp[i + 1][j + wv[i][0]] = max(dp[i][j] + wv[i][1], dp[i][j + wv[i][0]])
        
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])

print(dp[N][W])
### BUGGY CODE ###

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

H,W,N = map(int,input().split())
D = defaultdict(bool)
B = []

for _ in range(N):
    a,b = map(lambda x: int(x)-1,input().split())
    D[(a,b)] = True
    B.append((a,b))

ans = [0 for _ in range(10)]

for a,b in B:
    for i in range(9):
        ix,iy = divmod(i,3)
        if a-ix<0 or b-iy<0:
            continue
        black_count = 0
        for j in range(9):
            jx,jy = divmod(j,3)
            if H<=a-ix+jx or W<=b-iy+jy:
                break
            if D[(a-ix+jx,b-iy+jy)]:
                if -ix+jx<0 or (-ix+jx==0 and -iy+jy<0):
                    break
                black_count += 1
        else:
            ans[black_count] += 1

ans[0] = (H-2)*(W-2)-sum(ans)
print(*ans,sep='\n')

### FIXED CODE ###

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

H,W,N = map(int,input().split())
D = defaultdict(bool)
B = []

for _ in range(N):
    a,b = map(lambda x: int(x)-1,input().split())
    D[(a,b)] = True
    B.append((a,b))

ans = [0 for _ in range(10)]

for a,b in B:
    for i in range(9):
        ix,iy = divmod(i,3)
        if a-ix<0 or b-iy<0:
            continue
        black_count = 0
        for j in range(9):
            jx,jy = divmod(j,3)
            if H<=a-ix+jx or W<=b-iy+jy:
                break
            if (a-ix+jx,b-iy+jy) in D:
                if -iy+jy<0 or (-iy+jy==0 and -ix+jx<0):
                    break
                black_count += 1
        else:
            ans[black_count] += 1

ans[0] = (H-2)*(W-2)-sum(ans)
print(*ans,sep='\n')
### BUGGY CODE ###

def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    S = input()

    import re
    num_li = [False]*1000
    for i in range(1000):
        pattern = r'{0[0]}.*{0[1]}.*{0[2]}'.format(list('{:3d}'.format(i))).replace(' ','0')
        # print(i,pattern)
        if re.search(pattern,S):
            num_li[i]=True
            
    print(sum(num_li))

if __name__=='__main__':
    main()

### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    S = input()

    import re
    num_li = [False]*1000
    for i in range(10):
        first_ = S.find(str(i),0,N-2)
        if first_==-1:
            continue
        for j in range(10):
            second_ = S.find(str(j),first_+1,N-1)
            if second_==-1:
                continue
            for k in range(10):
                third_ = S.find(str(k),second_+1,N)
                if third_==-1:
                    continue
                num_li[i*100+j*10+k]=True
            
    print(sum(num_li))

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

A,B,K=map(int,input().split())
tmp = set(range(A,B+1)) & (set(range(A,A+K)) | set(range(B-K+1,B+1)))
[print(s) for s in sorted(tmp)]

### FIXED CODE ###

A,B,K=map(int,input().split())
tmp = set(range(A,min(B+1,A+K))) | set(range(max(A, B-K+1),B+1))
[print(s) for s in sorted(tmp)]
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    a=LI()
    def cmb(n, r, mod):
        if (r < 0) or (n < r):
            return 0
        r = min(r, n - r)
        return (fact[n] * factinv[r] * factinv[n-r])%mod

    fact=[1,1]
    factinv=[1,1]
    inv=[0,1]
    
    for i in range(2, N + 5):
        fact.append((fact[-1] * i) % mod)
        inv.append((-inv[mod % i] * (mod // i)) % mod)
        factinv.append((factinv[-1] * inv[-1]) % mod)
        
    loc=[-1]*N
    mu=[-1,-1]
    for i in range(N+1):
        if loc[a[i]-1]==-1:
            loc[a[i]-1]=i
        else:
            mu[0]=loc[a[i]-1]
            mu[1]=i
    N1=mu[0]
    N2=N-mu[1]
    for i in range(N+1):
        if i==0:
            print(N)
        else:
            temp=0
            for j in range(i+1):
                temp+=cmb(N1,j,mod)*cmb(N2,i-j,mod)
                temp%=mod
                
            print((cmb(N+1,i+1,mod)-temp)%mod)
        
            
    
            
            
        


main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    a=LI()
    def cmb(n, r, mod):
        if (r < 0) or (n < r):
            return 0
        r = min(r, n - r)
        return (fact[n] * factinv[r] * factinv[n-r])%mod

    fact=[1,1]
    factinv=[1,1]
    inv=[0,1]
    
    for i in range(2, N + 5):
        fact.append((fact[-1] * i) % mod)
        inv.append((-inv[mod % i] * (mod // i)) % mod)
        factinv.append((factinv[-1] * inv[-1]) % mod)
        
    loc=[-1]*N
    mu=[-1,-1]
    for i in range(N+1):
        if loc[a[i]-1]==-1:
            loc[a[i]-1]=i
        else:
            mu[0]=loc[a[i]-1]
            mu[1]=i
    N1=mu[0]
    N2=N-mu[1]
    
    for i in range(N+1):
        if i==0:
            print(N)
        else:   
            print((cmb(N+1,i+1,mod)-cmb(N1+N2,i,mod))%mod)
        
            
    
            
            
        


main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
#from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [LI()for i in range(n)]
inf = 10**17
mod = 10**9 + 7

s=input().rstrip()
l=len(s)
dp=[[0 for i in range(13)] for i in  range(l)]
#dp[0]=[1 for i in range(13)]
i=0
u=s[0]
if u!="?":
    k=(int(u)*10**(l-1))%13
    dp[0][k]+=1
else:
    for g in range(10):
        k=(g*10**(l-1))%13
        dp[0][k]+=1
#print(dp)
for i in range(l-1):
    u=s[i+1]
    for j in range(13):
        if u!="?":
            k=(j+int(u)*(10**(l-i-2)))%13
            dp[i+1][k]+=dp[i][j]
        else:
            for g in range(10):
                k=(j+g*10**(l-i-2))%13
                dp[i+1][k]+=dp[i][j]
            
#print(dp)
print(dp[l-1][5]%mod)
        

### FIXED CODE ###

import sys,math,copy

def main():
    # import numpy as np
    input = sys.stdin.readline
    S = ''.join(reversed(input().strip()))

    # dp = np.zeros((13), dtype=int)
    # dp_ = np.zeros((13), dtype=int)
    dp = [0] * 13
    dp_ = [0] * 13
    mod13_list = [i % 13 for i in range(12 ** 2 + 1)]
    list10 = list(range(10))
    list13 = list(range(13))
    divisor = 10 ** 9 + 7
    dp_[0] = 1
    mul = 1
    for i in range(len(S)):
        s = S[i]
        if s == '?':
            for d in list10:
                m = mod13_list[(d * mul)]
                for pm in list13:
                    dp[mod13_list[(pm+m)]] += dp_[pm]

        else:
            si = int(s)
            m = mod13_list[(si * mul)]
            for pm in list13:
                dp[mod13_list[(pm+m)]] = dp_[pm]

        # dp_ = dp % divisor
        # dp = dp * 0 # np.zeros((13), dtype=int)
        for j in list13:
            dp_[j] = dp[j] % divisor
            dp[j] = 0
        mul = mod13_list[(mul * 10)]
    print(dp_[5])

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

def main():
    from itertools import combinations

    n, k = map(int, input().split())
    xy = [list(map(int, input().split())) for _ in range(n)]

    res = []
    for pattern in combinations(range(n), k):
        p_x = []
        p_y = []
        for i in pattern:
            x, y = xy[i]
            p_x.append(x)
            p_y.append(y)
        s = abs(max(p_x) - min(p_x)) * abs(max(p_y) - min(p_y))
        res.append(s)

    print(min(res))


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline


def main():
    n, k = map(int, input().split())
    X, Y = [], []
    for _ in range(n):
        x, y = map(int, input().split())
        X.append(x)
        Y.append(y)
    X_s = sorted(X)
    Y_s = sorted(Y)
    f_inf = float("inf")
    res = f_inf

    for x1 in range(n):
        for x2 in range(x1 + 1, n):
            for y1 in range(n):
                for y2 in range(y1 + 1, n):
                    lx, rx = X_s[x1], X_s[x2]
                    by, uy = Y_s[y1], Y_s[y2]
                    cnt = 0
                    for i in range(n):
                        if lx <= X[i] <= rx and by <= Y[i] <= uy:
                            cnt += 1
                    if cnt >= k:
                        res = min(res, abs(rx - lx) * abs(uy - by))
    print(res)


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

a, b, m = map(int, input().split())
ax = list(map(int, input().split()))
bx = list(map(int, input().split()))
x = []
for i in range(m):
    _x = map(int, input().split())
    x.append(list(_x))

min_sum = 99999999
for i in range(a):
    for j in range(b):
        sum = ax[i] + bx[j]
        for k in x:
            sum2 = sum
            if k[0] == i+1 and k[1] == j+1:
                sum2 = sum2 - k[2]
            if sum2 < min_sum:
                min_sum = sum2

print("{}".format(min_sum))

### FIXED CODE ###

a, b, m = map(int, input().split())
ax = list(map(int, input().split()))
bx = list(map(int, input().split()))
x = []
for i in range(m):
    _x = map(int, input().split())
    x.append(list(_x))

min_a = min(ax)
min_b = min(bx)
min_sum = min_a + min_b

for k in x:
    sum = ax[k[0]-1] + bx[k[1]-1] - k[2]
    if sum < min_sum:
        min_sum = sum

print("{}".format(min_sum))
### BUGGY CODE ###

def power(a, b, p): #a^b (mod p)を求める #二分累乗法を使う
    if b == 0:
        return 1
    elif b % 2 == 0:
        x = power(a, b//2, p)
        return x ** 2 % p
    elif b % 2 == 1:
        y = power(a, b-1, p)
        return a * y % p

def comb(a, b, p): #(a+b)!/a!b! (mod p)を求める #power関数を使う
    from math import factorial
    if a<0 or b<0:
        return 0
    if a==0 or b==0:
        return 1
    A = factorial(a)
    B = factorial(b)
    AB = factorial(a+b)
    return (AB * power(A,p-2,p) * power(B,p-2,p)) % p

H, W, A, B = map(int, input().split())
C = H - A
D = W - B
p = 1000000007

x = 0
for i in range(C):
    x += (comb(i, B-1, p) * comb(D-1, H-i-1, p)) % p
print(x % p)


### FIXED CODE ###

H, W, A, B = map(int, input().split())
C = H - A
D = W - B
p = 1000000007

def power(a, b): #a^b (mod p)を求める #二分累乗法を使う
    if b == 0:
        return 1
    elif b % 2 == 0:
        return power(a, b//2) ** 2 % p
    else:
        return power(a, b//2) ** 2 * a % p

f = [1] #f[i] = i! % p
for i in range(H+W):
    f.append(f[i] * (i+1) % p)

I_f = [0] * (H+W+1) #I_f[i] = (i!)^(-1) % p
I_f[H+W] = power(f[H+W], p-2)
for i in reversed(range(H+W)):
    I_f[i] = I_f[i+1] * (i+1) % p

def combi(a, b): #(a+b)!/a!b! (mod p)を求める
    return f[a+b] * I_f[a] * I_f[b] % p

x = 0
for i in range(C):
    x = (x + combi(i, B-1) * combi(D-1, H-i-1)) % p
print(x)
### BUGGY CODE ###

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

ans = 0

a_set = set(a_li)

for i in a_set:
    s = a_li.count(i)
    s += a_li.count(i-1)
    s += a_li.count(i+1)
    
    ans = max(ans,s)

print(ans)

### FIXED CODE ###

from collections import defaultdict

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

a_li.sort()
a_count = defaultdict(int)
for x in a_li:
    a_count[x] += 1

ans = 0

a_set = set(a_li)

for i in a_set:
    s = a_count[i] + a_count[i-1] + a_count[i+1]
    ans = max(ans,s)

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

h,w = map(int,input().split())
S = [input() for i in range(h)]

A = [[[0,0] for i in range(w)] for j in range(h)]

a = -1
b = -1
for i in range(h):
    a = -1
    for j in range(w):
        if S[i][j] == "#":
            if a != -1:
                for k in range(a,j):
                    A[i][k][0] = j-a
                a = -1
        else:
            if a == -1:
                a = j
                #print(j)
    if a != -1:
        for k in range(a,j+1):
            A[i][k][0] = j+1-a

for i in range(w):
    a = -1
    for j in range(h):
        if S[j][i] == "#":
            if a != -1:
                for k in range(a,j):
                    A[k][i][1] = j-a
                a = -1
        else:
            if a == -1:
                a = j
    if a != -1:
        for k in range(a,j+1):
            A[k][i][1] = j+1-a
#print(A)

ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, A[i][j][0] + A[i][j][1])

print(ans-1)

### FIXED CODE ###

h,w = map(int,input().split())
S = [input() for i in range(h)]

A = [[0 for i in range(w)] for j in range(h)]

a = -1
b = -1
for i in range(h):
    a = -1
    for j in range(w):
        if S[i][j] == "#":
            if a != -1:
                for k in range(a,j):
                    A[i][k] += j-a
                a = -1
        else:
            if a == -1:
                a = j
                #print(j)
    if a != -1:
        for k in range(a,j+1):
            A[i][k] += j+1-a

for i in range(w):
    a = -1
    for j in range(h):
        if S[j][i] == "#":
            if a != -1:
                for k in range(a,j):
                    A[k][i] += j-a
                a = -1
        else:
            if a == -1:
                a = j
    if a != -1:
        for k in range(a,j+1):
            A[k][i] += j+1-a
#print(A)

ans = 0
for i in range(h):
    ans = max(ans, max(A[i]))

print(ans-1)
### BUGGY CODE ###

N, K = list(map(int, input().split()))
h = list(map(int, input().split()))

INF = float('inf')
dp = [0]

for i in range(1, N):
    min_t = INF
    for j in range(1, K+1):
        if i - j < 0:
            continue
        min_t = min(min_t, dp[i-j] + abs(h[i-j] - h[i]))
    dp.append(min_t)

print(dp[N-1])


### FIXED CODE ###

N, K = list(map(int, input().split()))
h = list(map(int, input().split()))

INF = float('inf')
dp = [0]

for i in range(1, N):
    min_t = INF
    for j in range(1, K+1):
        if i - j < 0:
            continue
        min_t = min(min_t, dp[i-j] + abs(h[i-j] - h[i]))
    dp.append(min_t)

print(dp[N-1])
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
a2 = []
for i in range(n):
    a2.append(a[i]-i-1)
a3 = []
for i in range(n):
    m = min(a2)
    a3.append(m)
    a2.remove(m)
if n % 2 == 0:
    b = (a3[n//2-1]+a3[n//2])//2
else:
    b = a3[n//2]
s = 0
for i in a3:
    s += abs(i-b)
print(s)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a2 = []
mi = 0
for i in range(n):
    a2.append(a[i]-i-1)
a3 = sorted(a2)
if n % 2 == 0:
    b = (a3[n//2-1]+a3[n//2])//2
else:
    b = a3[n//2]
s = 0
for i in a3:
    s += abs(i-b)
print(s)
### BUGGY CODE ###

def MAIN():
    H, W = map(int, input().split())
    MAP = tuple(input() for _ in range(H))
    R, C = map(int, input().split())
    PTN = tuple(input() for _ in range(R))
    def solve(a, b):
        k = 0
        for i in range(a, a + R):
            if MAP[i][b:b + C] == PTN[k]:
                k += 1
            else:
                return False
        return True
    ans = []
    for i in range(H - R + 1):
        for j in range(W - C + 1):
            if solve(i, j):
                ans.append(f"{i} {j}")
    if ans:
        print("\n".join(a for a in ans))
MAIN()



### FIXED CODE ###

base1 = 1009
base2 = 1013
mask = (1 << 32) - 1
def calc_hash(f, r, c):
    global ph, pw, h
    tmp = [[0] * c for _ in range(r)]
    dr, dc = r - ph, c - pw
    # t1 = 1
    t1 = (base1 ** pw) & mask
    # for _ in range(pw):
        # t1 = (t1 * base1) & mask
    for i in range(r):
        e = 0
        for j in range(pw):
            e = e * base1 + f[i][j]
        for j in range(dc):
            tmp[i][j] = e
            e = (e * base1 - t1 * f[i][j] + f[i][j + pw]) & mask
        tmp[i][dc] = e
    t2 = 1
    for _ in range(ph):
        t2 = (t2 * base2) & mask
    for j in range(dc + 1):
        e = 0
        for i in range(ph):
            e = e * base2 + tmp[i][j]
        for i in range(dr):
            h[i][j] = e
            e = (e * base2 - t2 * tmp[i][j] + tmp[i + ph][j]) & mask
        h[dr][j] = e
th, tw = map(int, input().split())
t = tuple(tuple(ord(c) for c in input()) for _ in range(th))
ph, pw = map(int, input().split())
p = tuple(tuple(ord(c) for c in input()) for _ in range(ph))
ans = []
if th >= ph and tw >= pw:
    h = [[0] * tw for _ in range(th)]
    calc_hash(p, ph, pw)
    key = h[0][0] & mask
    calc_hash(t, th, tw)
    for i in range(th - ph + 1):
        for j in range(tw - pw + 1):
            if h[i][j] & mask == key:
                ans.append(f"{i} {j}")
if ans:
    print("\n".join(a for a in ans))
### BUGGY CODE ###

s = input()
s_x = [i for i in s if 'x' not in i]

cnt = 1
a, b = ' ', ''
for c in s:
    if c == 'x':
        pass
    elif c != s_x[len(s_x)-cnt]:
        print(-1)
        break
    else:
        cnt += 1
    d = len(s_x)/2
    if cnt <= d+1:
        a += c
        if c == 'x' and cnt > d:
            b += c
    elif cnt > d:
        b += c
else:
    b = ' ' + b[::-1]
    ans = 0
    i, j = 0, 0
    while i < len(a)-1 or j < len(b)-1:
        if i >= len(a):
            i -= 1
        if j >= len(b):
            j -= 1
        if a[i] == b[j]:
            i += 1
            j += 1
        elif a[i] == 'x':
            i += 1
            ans += 1
        elif b[j] == 'x':
            j += 1
            ans += 1
    print(ans)

### FIXED CODE ###

s = input()

i, j = 0, len(s)-1
ans = 0
while i < j:
    if s[i] == s[j]:
        i, j = i+1, j-1
    elif s[i] == 'x':
        i += 1
        ans += 1
    elif s[j] == 'x':
        j -= 1
        ans += 1
    else:
        ans = -1
        break

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

n,k,l=map(int,input().split())
def maketree(n,k,target):
    road=[]
    roadidx=[-1 for _ in range(n)]
    for i in range(len(target)):
        p=target[i][0]
        q=target[i][1]
        pidx=roadidx[p]
        qidx=roadidx[q]
        if pidx==-1 and qidx==-1:
            road.append({p,q})
            roadidx[p]=len(road)-1
            roadidx[q]=len(road)-1
        elif pidx==-1 and qidx!=-1:
            road[roadidx[q]]|={p,}
            roadidx[p]=qidx
        elif pidx!=-1 and qidx==-1:
            road[roadidx[p]]|={q,}
            roadidx[q]=pidx
        elif pidx!=qidx:
            x=road[roadidx[p]]|road[roadidx[q]]
            y=min(pidx,qidx)
            z=max(pidx,qidx)
            road[y]=x
            road[z]=x
            for j in x:
                roadidx[j]=y
    resroad=[]
    for i in road:
        if i not in resroad:resroad.append(i)
    return resroad

road = []
for i in range(k):
        p,q=map(int,input().split())
        p-=1
        q-=1
        road.append([p,q])
metro=[]
for i in range(l):
        r,s=map(int,input().split())
        r-=1
        s-=1
        metro.append([r,s])
roadtree=maketree(n,k,road)
metrotree=maketree(n,l,metro)
ans=[]
for i in roadtree:
    for j in metrotree:
        ans.append(i & j)

result=[1 for i in range(n)]
while len(ans)>0:
    x=ans.pop()
    for i in x:
        result[i]=len(x)
        
res=''
for i in range(n):
    res=res+str(result[i])+' '
print(res)

### FIXED CODE ###

import sys
input=sys.stdin.readline
N,K,L=map(int,input().split())
road=[tuple(map(int,input().split())) for _ in range(K)]
metro=[tuple(map(int,input().split())) for _ in range(L)]
inf=float('inf')
def Find(root,x):
    if root[x]<0:
        return x
    if root[x]>=0:
        root[x]=Find(root,root[x])
        return root[x]

def UnionFind(N,branch):
    root=[-1]*(N+1)
    for a,b in branch:
        aroot=Find(root,a)
        broot=Find(root,b)
        if aroot==broot:continue
        elif root[aroot]<=root[broot]:
            root[aroot]+=root[broot]
            root[broot]=aroot
        elif root[aroot]>root[broot]:
            root[broot]+=root[aroot]
            root[aroot]=broot
    return root
r_root=UnionFind(N,road)
m_root=UnionFind(N,metro)
from collections import defaultdict
data=[]
cnt=defaultdict(int)
for i in range(1,N+1):
    ri=Find(r_root,i)
    mi=Find(m_root,i)
    data.append((ri,mi))
    cnt[(ri,mi)]+=1
ans=''
for d in data:
    ans+=str(cnt[d])+' '
print(ans[:-1])