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

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


for i in range(N):
    tujyo=0
    S=0

    for k in range(N):
        if i!=k:
            
            tujyo+=abs(A[k]-S)
            S=A[k]
          
    tujyo+=abs(0-S)
    print(tujyo)

### FIXED CODE ###


N=int(input())

A=list(map(int,input().split()))
A=[0]+A+[0]

S=0
tujyo=0
for i in range(N+2):
    
            
    tujyo+=abs(A[i]-S)
    S=A[i]
          


for k in range(1,N+1):
    mae=A[k-1]
    usiro=A[k+1]
    if mae<= A[k]<=usiro or usiro<= A[k]<=mae:
        print(tujyo)
    else:
        print(tujyo-abs(A[k]-mae)-abs(usiro-A[k])+abs(usiro-mae))
### BUGGY CODE ###

import numpy as np
import heapq

INF=10**12
N,M=map(int,input().split())
adj=[[] for i in range(N)]
for i in range(M):
    L,R,C=map(int,input().split())
    L-=1
    R-=1
    adj[L].append((R,C))
    adj[R].append((L,C))
for i in range(N-1):
    adj[i+1].append((i,0))
    
s=0
g=N-1
used=np.array([])
heap=[]
table=np.array([INF for i in range(N)])
table[s]=0
heapq.heappush(heap,(table[s],s))
used=np.append(used,s)
                
while heap and not(g in used):
    q=heapq.heappop(heap)
    a=q[1]
    used=np.append(used,a)
    for ne in adj[a]:
        p=ne[0]
        co=ne[1]
        if not(p in used):
            table[p]=min(table[p],table[a]+co)
            heapq.heappush(heap,(table[p],p))
ans=table[g]
if ans==INF:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

import numpy as np
import heapq

INF=10**15
N,M=map(int,input().split())
adj=[[] for i in range(N)]
for i in range(M):
    L,R,C=map(int,input().split())
    L-=1
    R-=1
    adj[L].append((R,C))
    adj[R].append((L,C))
for i in range(N-1):
    adj[i+1].append((i,0))
    
s=0
g=N-1
heap=[]
table=np.array([INF for i in range(N)])
table[s]=0
heapq.heappush(heap,(table[s],s))
                
while heap:
    q=heapq.heappop(heap)
    a=q[1]
    if q[0]>table[a]: continue
    for ne in adj[a]:
        p=ne[0]
        co=ne[1]
        if table[p]>table[a]+co:
            table[p]=table[a]+co
            heapq.heappush(heap,(table[p],p))
ans=table[g]
if ans==INF:
    print(-1)
else:
    print(ans)
### BUGGY CODE ###

n = int(input())
s = str(input().replace(' ', ''))
cnt = [0 for i in range(n)]
conb = [0 for i in range(n)]
for i in range(n):
    cnt[i] = s.count(str(i + 1))
    conb[i] = cnt[i] * (cnt[i] - 1) // 2
Sum = sum(conb)
for k in range(n):
    ans = Sum - conb[int(s[k]) - 1] + (cnt[int(s[k]) - 1] - 1) * (cnt[int(s[k]) - 1] - 2) // 2
    print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
cnt = [0] * (n + 1)
for i in range(n):
    cnt[a[i]] += 1
conb1, conb2 = [], []
for i in range(n + 1):
    conb1.append(cnt[i] * (cnt[i] - 1) // 2)
    if cnt[i] == 0:
        conb2.append(0)
    else:
        conb2.append((cnt[i] - 2) * (cnt[i] - 1) // 2)
sumall = sum(conb1)
for i in range(n):
    ans = sumall - conb1[a[i]] + conb2[a[i]]
    print(ans)
### BUGGY CODE ###

n=int(input())
s=input()
ans=0
d=dict()
for i in range(n):
  t=""
  for j in range(i,n):
    t+=s[j]
    if d.get(t,0)==0:
      d[t]=j
    else:
      if d[t]<i:
        ans=max(ans,j-i+1)
print(ans)


### FIXED CODE ###

import collections
mod=10**9+7
base=257
n=int(input())
S=list(ord(s)-96 for s in input())
B=[0]*(n+1)
B[0]=1
for i in range(n):
  B[i+1]=(B[i]*base)%mod

def chk(x):
  ret=False
  h=0
  bx=B[x]
  d=collections.defaultdict(int)
  for i in range(x):
    h=(h*base+S[i])%mod
  d[h]=x
  for i in range(x,n):
    h=(h*base+S[i]-S[i-x]*bx)%mod
    if d[h]==0:
      d[h]=i+1
    elif d[h]<=i-x+1:
      ret=True
  return ret

l,r=0,n//2
while r-l>1:
  m=(l+r)//2
  if chk(m):
    l=m
  else:
    r=m
print(r if chk(r) else l)
### BUGGY CODE ###

import math

def pf(n):
    ans=[1]
    i=2
    while(n!=1):
        if (n%i==0):
            while(n%i==0):
                n=n/i
            ans.append(i)
        i+=1
    return ans

a,b = map(int,input().split())
pfa=pf(a)
pfb=pf(b)
ans=0
for i in pfa:
    if(i in pfb):
        ans+=1
print(ans)


### FIXED CODE ###

import math

def pf(n):
    ans=[1]
    i=2
    if(n%i==0):
        while(n%2==0):
            n = n/i
        ans.append(i)
    i+=1
    while(i<math.sqrt(n) and n!=1):
        if (n%i==0):
            while(n%i==0):
                n=n/i
            ans.append(i)
        i+=2
    if(n!=1):
        ans.append(n)
    return set(ans)

a,b = map(int,input().split())
pfa=pf(a)
a=0
for i in pfa:
    if(b%i==0):
        a+=1
print(a)
### BUGGY CODE ###

n = int(input())
ls = [int(elem) for elem in input().split()]

import itertools

res = 0
cands = itertools.combinations(ls, 3)
for a, b, c in cands:
    if a < (b + c) and b < (c + a) and c < (a + b):
        res += 1
print(res)


### FIXED CODE ###

import bisect

n = int(input())
ls = [int(elem) for elem in input().split()]
ls = sorted(ls)

cnt = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        k = bisect.bisect_left(ls, ls[i] + ls[j])
        k -= 1
        cnt += k - j
print(cnt)
### BUGGY CODE ###

import sys
from bisect import bisect_left

def main():
    input = sys.stdin.readline
    N, Q = map(int, input().split())
    closure = []
    for _ in range(N):
        start, end, pos = map(int, input().split())
        closure.append((pos, start, end))

    closure.sort()

    D = [int(input()) for _ in range(Q)]

    ans = [-1] * Q
    for pos, start, end in closure:
        left = bisect_left(D, start - pos)
        right = bisect_left(D, end - pos)

        while left < right:
            if ans[left] == -1:
                ans[left] = pos

            left += 1

    return ans


if __name__ == '__main__':
    print(*main(), sep='\n')


### FIXED CODE ###

# ref: https://atcoder.jp/contests/abc128/submissions/5654623

import sys
from bisect import bisect_left

def main():
    input = sys.stdin.readline
    N, Q = map(int, input().split())
    closure = []
    for _ in range(N):
        start, end, pos = map(int, input().split())
        closure.append((pos, start, end))

    closure.sort()

    D = [int(input()) for _ in range(Q)]

    ans = [-1] * Q
    skip = [-1] * Q
    for pos, start, end in closure:
        left = bisect_left(D, start - pos)
        right = bisect_left(D, end - pos)

        while left < right:
            if skip[left] == -1:
                ans[left] = pos
                skip[left] = right
                left += 1
            else:
                left = skip[left]

    return ans


if __name__ == '__main__':
    print(*main(), sep='\n')
### BUGGY CODE ###

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    a.sort()
    b = set()
    c = 0
    for i in range(n):
        if i < n - 1 and a[i] == a[i + 1]:
            b.add(a[i])
            continue
        for j in range(1, int(a[i]**0.5) + 1):
            if a[i] % j:
                continue
            if j in b or a[i] // j in b:
                break
        else:
            c += 1
            b.add(a[i])
    print(c)


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    a.sort()
    b = 0
    dp = [True] * (a[-1] + 1)
    for ai in a:
        if not dp[ai]:
            continue
        for j in range(ai * 2, a[-1] + 1, ai):
            dp[j] = False
        if ai == b:
            dp[ai] = False
        b = ai
    print(sum(dp[ai] for ai in a))


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

# -*- coding: utf-8 -*-

def main():
    # 入力
    st = input()

    if len(st) < 4:
        print(0)
        return

    # 右からi文字目から最後の数字までを数値化したものについてmodを計算していく
    mod_res_dic = {0: [0]}
    tmp_mod_val = 0
    r_st = ''.join(list(reversed(st)))
    for i in range(1, len(r_st) + 1):
        target_st = r_st[i-1:i]
        mod_res = ((((10 ** (i-1)) * int(target_st)) % 2019) + tmp_mod_val) % 2019
        ls = mod_res_dic.setdefault(mod_res, [])
        ls.append(i)
        tmp_mod_val = mod_res

    # print(mod_res_dic)
    # modが同じペアのものについて、iからj文字目までを2019で割り切れるので、その組み合わせを計算
    cnt = 0
    for v in mod_res_dic.values():
        comb = len(v)
        if comb < 2:
            continue
        cnt += (comb * (comb - 1)) / 2

    print(int(cnt))


main()


### FIXED CODE ###

# -*- coding: utf-8 -*-

def main():
    # 入力
    st = input()

    # if len(st) < 4:
    #     print(0)
    #     return

    # 右からi文字目から最後の数字までを数値化したものについてmodを計算していく
    mod_res_dic = {0: [0]}
    tmp_mod_val = 0
    r_st = ''.join(list(reversed(st)))
    cnt = 0
    for i in range(len(r_st)):
        target_st = r_st[i:i+1]
        # mod_res = ((10 ** i) * int(target_st) + tmp_mod_val) % 2019
        tmp_mod_val += int(target_st)*pow(10, i, 2019)
        tmp_mod_val %= 2019
        ls = mod_res_dic.setdefault(tmp_mod_val, [])
        ls.append(i-1)
        if len(ls) > 1:
            cnt += len(ls)-1
        # tmp_mod_val = mod_res

    # print(mod_res_dic)
    # modが同じペアのものについて、iからj文字目までを2019で割り切れるので、その組み合わせを計算
    # cnt = 0
    # for v in mod_res_dic.values():
    #     comb = len(v)
    #     if comb < 2:
    #         continue
    #     cnt += (comb * (comb - 1)) / 2

    print(int(cnt))


main()
### BUGGY CODE ###

import numpy as np
N = int(input())

P = list(map(int, input().split()))

P = [0] + P
     
count = 0
for i in range(1, N+1):
    if not any(P[i] > np.array(list(set(P[1:i+1])))):
        count += 1

print(count)

### FIXED CODE ###

N = int(input())

P = list(map(int, input().split()))

P = [0] + P
     
count = 0
min = 10000000000000
for i in range(1, N+1):
    if min > P[i]:
        min = P[i]
    elif min < P[i]:
        continue
    """
    for j in range(1, i+1):
        #print(i, P[i], j , P[j])
        if P[i] > P[j]:
            #print("out", i)
            break
    else:
        #print("ok", i)
        count += 1
    """
    count += 1
        
    if P[i] == 1:
        break

print(count)
### BUGGY CODE ###

from collections import Counter
N = int(input())
A = list(map(int, input().split()))
B = Counter(A)
seen = [-1]*(5*10**5)
nc2 = [-1]*(5*10**5)
for i in range(N):
    if seen[A[i]] != -1:
        print(seen[A[i]])
        continue
    B[A[i]] -= 1
    ans = 0
    for n in B.values():
        if nc2[n] != -1:
            ans += nc2[n]
            continue
        ans += n*(n-1)//2
    print(ans)
    seen[A[i]] = ans
    B[A[i]] += 1

### FIXED CODE ###

from collections import Counter
N = int(input())
A = list(map(int, input().split()))
B = Counter(A)

ans = 0
for i in B.values():
    ans += i*(i-1)//2

for a in A:
    k = B[a]
    print(ans - (k*(k-1)//2)+((k-1)*(k-2)//2))
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()
for i in range(Q):
    cnt = 0
    l, r = map(int, input().split())
    for i in range(l-1,r-1):
        if S[i] == 'A' and S[i+1] == 'C':
            cnt += 1
    print(cnt)

### FIXED CODE ###

# import math
N, Q = map(int, input().split())
# line = list(map(int, input().split()))
# line = input()
S = input()
question = []
ac = [0] * N
ans = []
count = 0
for _ in range(Q):
    question.append(list(map(int, input().split())))

for i in range(N):
    if S[i] == 'C' and S[i-1] == 'A':
        count += 1
        ac[i] = count
    else:
        ac[i] = count

# print(ac)

for i in range(Q):
    start = question[i][0] - 1
    end = question[i][1] - 1
    tmp = ac[end] - ac[start]
    ans.append(tmp)

for i in range(len(ans)):
    print(ans[i])
### BUGGY CODE ###

import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math
import functools

s = input()
li = [0]
c = 2019
for i in range(1,110):
    li.append(c*i)
cnt = 0
for i in range(len(li)):
    a = str(li[i])
    for j in range(len(s)-len(a)+1):
        c = ""
        for k in range(len(a)):
            c += s[j+k]
        if c == a:
            cnt += 1
print(cnt)

### FIXED CODE ###

import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
mod = 2019
if __name__ == "__main__":
    s = input()
    n = len(s)
    dp = [0]*(mod)
    dp[0] = 1
    r = 0
    t = 1
    for i in reversed(s):
        r += int(i)*t
        r%=mod
        t*=10
        t%=mod
        dp[r] +=1
    ans = 0
    for i in dp:
        ans += i*(i-1)//2
    print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

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

ans = 0
for i in range(1,1<<N):
    sum1 = 0
    cnt = 0
    for j in range(N):
        if i & 1<<j:
            sum1 += xN[j]
            cnt += 1
    if sum1 / cnt == A:
        ans += 1
        
print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-

""" 3次元DP """

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

# i(=xNリストからどこまでを選べる範囲とするか)からj(=0～N)枚選んで、選んだ値の合計をkにするような選び方の総数
dp = [[[0] * (N*X+1) for j in range(N+1)] for i in range(N+1)]
dp[0][0][0] = 1

ans = 0
for i in range(1,N+1):
    for j in range(N+1):
        for k in range(N*X+1):
            # 求めたい合計(k)が、この周回で増えた選択肢(xN[i-1])より小さい場合、
            # 選び方の総数は増える見込みがないので前回の値をそのまま使用
            if k < xN[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            # 合計kが大きければ、増やせるかもしれないので、選んだ数と合計を減らしたところを見に行く
            # 選べる数j=0は論外だし、添え字[j-1]に良くないので条件で除外する
            elif k >= xN[i-1] and j > 0:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-xN[i-1]]
            # 選んだ数と合計から判断して、平均が条件に合うものなら答えに足す
            if i == N and j > 0 and k == j*A:
                ans += dp[i][j][k]

# ans = 0
# for k in range(1,N+1):
#     ans += dp[N][k][k*A]
        
print(ans)
### BUGGY CODE ###

N,K=map(int, input().split())
a=list(map(int, input().split()))
x=0
len_bin=len(bin(K))-2

def bin_l(n,i):
    return n%(2**(len_bin-i))>>(len_bin-i-1)

for i in range(len_bin):
    zero=0
    one=0
    for j in range(N):
        if bin_l(a[j],i)==0:
            zero+=1
        else:
            one+=1
    x=x<<1
    if zero>one and x<(K>>(len_bin-i-1)):
        x+=1

ans=0
for i in range(N):
    ans+=x^a[i]
print(ans)

### FIXED CODE ###

N,K=map(int, input().split())
a=list(map(int, input().split()))
x=0
len_bin=len(bin(K))-2

def bin_l(n,i):
    return (n>>(len_bin-i-1))%2

for i in range(len_bin):
    zero=0
    one=0
    for j in range(N):
        if bin_l(a[j],i)==0:
            zero+=1
        else:
            one+=1
    x=x<<1
    if zero>one and x<(K>>(len_bin-i-1)):
        x+=1

ans=0
for i in range(N):
    ans+=x^a[i]
print(ans)
### BUGGY CODE ###

import sys
from collections import deque

sys.setrecursionlimit(10000000)

readline = sys.stdin.readline

N, M = map(int, readline().split())
uv = [list(map(int, readline().split())) for i in range(M)]
S, T = map(int, readline().split())

S, T = S - 1, T - 1

nodes = [{} for i in range(N)]
for u, v in uv:
    nodes[u - 1][v - 1] = 1

visited = [False] * N

def kenken(u, rem):
    if rem > 0:
        a = []
        for v in nodes[u]:
            a += kenken(v, rem - 1)
        return a
    else:
        return [u]
    

q = deque()

q.append([S, 0])

_count = -1
while len(q) != 0:
    u, count = q.popleft()
    if not visited[u]:
        visited[u] = True

        ret = kenken(u, 3)
        if any(T == r for r in ret):
            _count = count + 1
            break
        q.extend([r, count + 1] for r in ret)


print(_count)

### FIXED CODE ###

import sys
from collections import deque

sys.setrecursionlimit(10000000)

readline = sys.stdin.readline

N, M = map(int, readline().split())
uv = [list(map(int, readline().split())) for i in range(M)]
S, T = map(int, readline().split())

S, T = S - 1, T - 1

nodes = [{} for i in range(N)]
for u, v in uv:
    nodes[u - 1][v - 1] = 1

visited = [[False] * N for i in range(3)]

def kenken(u, rem):
    if rem != 3 and visited[rem][u]:
        return deque()
    
    if rem != 3:
        visited[rem][u] = True
    if rem > 0:
        a = deque()
        for v in nodes[u]:
            a.extend(kenken(v, rem - 1))
        return a
    else:
        return deque([u])
    

q = deque()

q.append([S, 0])

_count = -1
while len(q) != 0:
    u, count = q.popleft()

    ret = kenken(u, 3)
    if any(T == r for r in ret):
        _count = count + 1
        break
    q.extend([r, count + 1] for r in ret)


print(_count)
### BUGGY CODE ###

from functools import reduce
input()
src = input()
costs = [reduce(lambda x,y: x+(1 if y=="#" else 0), src[:i], 0) + reduce(lambda x,y: x+(1 if y=="." else 0), src[i:], 0) for i in range(len(src))]
costs.append(reduce(lambda x,y: x+(1 if y=="#" else 0), src, 0))
print(min(costs))

### FIXED CODE ###

from functools import reduce
l = int(input())
src = list(map(lambda x: 1 if x=="." else 0, input()))
left_black = 0
right_white = sum(src)
ans = right_white
for i in range(l):
  if src[i]==0:
    left_black+=1
  else:
    right_white-=1
  ans = min(ans, left_black + right_white)
  if ans==0:
    break
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
p = [int(x) for x in input().split()]

x = []
oklist = [0]

for i in range(1,n):
    res = "ok"
    for j in range(i):
        #print(j,i,p[j],p[i])
        if p[j] < p[i]:
            res = "ng"
            break
    if res == "ok":
        oklist.append(i)

print(len(oklist))

### FIXED CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
p = [int(x) for x in input().split()]

ok = 1
minp = [p[0]]

for i in range(1,n):
    if p[i] < minp[i-1]:
        minp.append(p[i])
        ok = ok + 1
    else:
        minp.append(minp[i-1])

print(ok)
### BUGGY CODE ###

#2
s = list(input())
l = len(s)
cnt = 0

for i in range(l*l):
    for j in range(l-1):
        if s[j] =="B" and s[j+1] == "W":
            cnt += 1
            s[j],s[j+1] = s[j+1],s[j]
            break
        
print(cnt)

### FIXED CODE ###

s=input()

ans=0
b_cnt=0
for i in range(len(s)):
  if s[i]=='B':
    b_cnt+=1
  else:
    ans+=b_cnt

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

s = input()
while 'ST' in s:
    s = s.replace('ST', '')
print(len(s))

### FIXED CODE ###

x = input()
count_s = 0
ans = 0
for i in range(len(x)):
    if x[i] == 'S':
        count_s += 1
    if x[i] == 'T':
        if count_s == 0:
            ans += 1
        else:
            count_s -= 1
ans += count_s
print(ans)
### BUGGY CODE ###

a = int(input())
i = 1
q = 1
for a in range(a):
 i = i*q
 q = q+1
w = i%(10**9+7)
print(w)

### FIXED CODE ###

n = int(input())
ans = 1
for i in range(1,n+1):ans=(ans*i)%(10**9 + 7)
print(ans)
### BUGGY CODE ###

n=int(input())
s=list(input())
result=[]
for i in range(n):
  total=0
  for j in range(n):
    if j == i: continue
    if i < j and s[j] == 'E': total+=1
    if i > j and s[j] == 'W': total+=1
  result.append(total)
print(min(result))

### FIXED CODE ###

n = int(input())
s = list(input())

# W,E各々の累積和を求めておく
cumulative_e = [0] * (n+1)
cumulative_w = [0] * (n+1)
for i in range(1, n+1):
  if s[i-1] == 'W':
    cumulative_w[i] = cumulative_w[i-1] + 1
    cumulative_e[i] = cumulative_e[i-1]
  elif s[i-1] == 'E':
    cumulative_e[i] = cumulative_e[i-1] + 1
    cumulative_w[i] = cumulative_w[i-1]

# 誰がリーダーに適任か調べる
result = [0] * n
for j in range(n):
  result[j] = cumulative_w[j] + ( cumulative_e[n] - cumulative_e[min(n,j+1)])

print(min(result))
### BUGGY CODE ###

import itertools

N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10**9 + 7

# print(A * K)

ans = 0
meets = [0] * N
for i in range(N):
    for j in range(N):
        ans += int(i < j and A[i] > A[j])
        meets[i] += int(A[i] > A[j])
ans *= K
# print(meets)

ans += sum(meets) * K * (K - 1) // 2

print(ans % MOD)


### FIXED CODE ###

import itertools

N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10**9 + 7

# print(A * K)

ans = 0
meets = [0] * N
for i in range(N):
    for j in range(N):
        ans += int(i < j and A[i] > A[j])
        meets[i] += int(A[i] > A[j])
ans *= K
# print(meets)

ans += sum(meets) * K * (K - 1) // 2

print(ans % MOD)
### BUGGY CODE ###

n = int(input())
p = list(map(int, input().split()))
count = 0
tof = True

for i in range(n):
  for j in range(i):
    if p[j] >= p[i]:
      continue
    else:
      tof = False
      break
  if tof:
    count += 1
  else:
    tof = True
  
print(count)

### FIXED CODE ###

n = int(input())
p = list(map(int, input().split()))
count = 0
m = [0] * n

memo = n
for i in range(n):
    if memo > p[i]:
        m[i] = p[i]
        memo = p[i]
    else:
        m[i] = memo

for i in range(1, n+1):
    if p[i-1] <= m[i-1]:
        count += 1

print(count)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
s = sum(a)
print(*[s-2*(sum(a[i-2::-2]) if i>1 else 0)-2*sum(a[i+1::2]) for i in range(n)])

### FIXED CODE ###

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

# m0 + m1 + m2 + m3 + m4 = d0 + d1 + d2 + d3 + d5
# d0 = (m0 + m1)//2
# d1 = (m1 + m2)//2
# d2 = (m2 + m3)//2
# d3 = (m3 + m4)//2
# d4 = (m4 + m0)//2
# m0 =  d0 - d1 + d2 - d3 + d4
# m1 =  d0 + d1 - d2 + d3 - d4
# m2 = -d0 + d1 + d2 - d3 + d4
# m3 =  d0 - d1 + d2 + d3 - d4
# m4 = -d0 + d1 - d2 + d3 + d4   
s = sum(a)
p = [0 for _ in range(n)]
q = [0 for _ in range(n+1)]
for i in range(n) :
    if i>1 :
        p[i] = p[i-2] + a[i-2]
    q[n-i-2] = q[n-i] + a[n-i-1]

print(*[s-2*p[i]-2*q[i] for i in range(n)])
### BUGGY CODE ###

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

class UnionFind(object):
    def __init__(self, N):
        self.parent = [-1] * N

    def root(self, A):
        if self.parent[A-1] < 0:
            return A
        self.parent[A-1] = self.root(self.parent[A-1])
        return self.parent[A-1]

    def size(self, A):
        if self.parent[A-1] < 0:
            return -1 * self.parent[A-1]
        return -1 * self.parent[self.root(A)-1]

    def connect(self, A, B):
        A = self.root(A)
        B = self.root(B)
        if A == B:
            return False
        
        if self.size(A) < self.size(B):
            A, B = B, A
        
        self.parent[A-1] += self.parent[B-1]
        self.parent[B-1] = A
        return True
        
uni1 = UnionFind(N)
for _ in range(K):
    p, q = map(int, input().split())
    if uni1.root(p) != uni1.root(q):
        uni1.connect(p,q)

uni2 = UnionFind(N)
for _ in range(L):
    r, s = map(int, input().split())
    if uni2.root(r) != uni2.root(s):
        uni2.connect(r,s)

# print (uni1.parent)
# print (uni2.parent)

for i in range(1, N+1):
    ans = 0
    for j in range(1, N+1):
        # print (uni1.root(i), uni1.root(j), uni2.root(i), uni2.root(j))
        if uni1.root(i) == uni1.root(j) and uni2.root(i) == uni2.root(j):
            ans += 1
    print (ans, end = ' ')
print ()

# print (uni1.parent)
# print (uni2.parent)


### FIXED CODE ###

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

class UnionFind(object):
    def __init__(self, N):
        self.parent = [i for i in range(N)]

    def root(self, A):
        if self.parent[A] == A:
            return A
        self.parent[A] = self.root(self.parent[A]) #経路縮約
        return self.parent[A]

    def connect(self, A, B):
        A = self.root(A)
        B = self.root(B)
        self.parent[A] = B
        
uni1 = UnionFind(N)
for _ in range(K):
    p, q = map(int, input().split())
    if uni1.root(p-1) != uni1.root(q-1):
        uni1.connect(p-1,q-1)

uni2 = UnionFind(N)
for _ in range(L):
    r, s = map(int, input().split())
    if uni2.root(r-1) != uni2.root(s-1):
        uni2.connect(r-1,s-1)

# print (uni1.parent)
# print (uni2.parent)

ans = dict()
key_list = []
for i in range(N):
    root1 = uni1.root(i)
    root2 = uni2.root(i)
    key = str(root1) + '_' + str(root2)
    key_list += [key]
    if key in ans.keys():
        ans[key] += 1
    else:
        ans[key] = 1
    
for i in range(N):
    print (ans[key_list[i]], end = ' ')
print ()






# for i in range(1, N+1):
#     ans = 0
#     for j in range(1, N+1):
#         # print (uni1.root(i), uni1.root(j), uni2.root(i), uni2.root(j))
#         if uni1.root(i) == uni1.root(j) and uni2.root(i) == uni2.root(j):
#             ans += 1
#     print (ans, end = ' ')
print ()

# print (uni1.parent)
# print (uni2.parent)