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

# 初期入力
import numpy as np 
N,Q = (int(x) for x in input().split())
aa=0  
bb=0
a=[0] 
b=[0]
a_set =set()
ki_kouzou =np.zeros((N+1,1),dtype=np.int32)
ki_kouzou_dic ={i:set() for i in range(1,N+1)}

#木の構造を入力
for i in range(1,N): #直接つながっているところ。
    aa,bb = (int(x) for x in input().split())
    if bb in a_set: #親子判定 頂点3⇒頂点2もありうる
        #np.append(ki_kouzou[bb,:],aa,axis=1)
        a_set.add(aa)
        ki_kouzou_dic[bb].add(aa)
    else:
        #np.append(ki_kouzou[aa,:],bb,axis=1)
        #ki_kouzou[aa].append(bb)
        ki_kouzou_dic[aa].add(bb)
        a_set.add(bb)
    a.append(aa)     
    b.append(bb)


#間接的に繋がっているところ
kansetu ={i:set() for i in range(1,N+1)}
for ki_key in range(1,N+1) :
    for v_v in ki_kouzou_dic[ki_key]:
        if v_v in ki_kouzou_dic.keys():
            kansetu[ki_key] = kansetu[ki_key] | ki_kouzou_dic[v_v] 

for i in range(1,N+1):
    ki_kouzou_dic[i] =ki_kouzou_dic[i] | kansetu[i] #直接 ＋ 間接
    ki_kouzou_dic[i].add(i) #各頂点自身はは必ずポイント加算あり


# ポイント入力-計算
point={i:0 for i in range(1,N+1)}
pp=0 ; xx=0
for _ in range(Q):
    pp,xx = (int(x) for x in input().split())
    for i in ki_kouzou_dic[pp]:
        point[i] += xx 

print(*point.values())

### FIXED CODE ###

from collections import OrderedDict
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
#初期データ、構造
N,Q = (int(x) for x in input().split())
connection ={i:set() for i in range(1,N+1)}
for i in range(N-1):
    a,b = (int(x) for x in input().split())
    connection[a].add(b)
    connection[b].add(a)
#point =OrderedDict({i:0 for i in range(1,N+1)})
point ={i:0 for i in range(1,N+1)}
for i in range(Q):
    p,x = (int(x) for x in input().split())
    point[p] +=x

def DFS(now,prev = -1):
    for next in connection[now]:
        if next == prev:
            continue
        point[next] +=point[now] 
        DFS(next,now)

DFS(1)
print(*point.values())
### BUGGY CODE ###

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

for i in range(Q):
    B, C = map(int, input().split())

    while B in A:
        A[A.index(B)] = C

    print(sum(A))

### FIXED CODE ###

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

data = [0] * 100001

def my_sum(d):
    retval = 0

    for i in range(len(d)):
        if d[i] == 0:
            continue
        retval += d[i] * i
    return retval

for i in A:
    data[i] += 1

sum_val = my_sum(data)

for i in range(Q):
    B, C = map(int,input().split())

    sum_val = sum_val - (data[B] * B) + (data[B] * C)

    data[C] += data[B]
    data[B] = 0

    print(sum_val)
### BUGGY CODE ###

import sys

sys.setrecursionlimit(100000)

n,q=map(int, input().split())
ab=[]
for _ in range(n):
    ab.append([])
for _ in range(n-1):
    a,b=map(int, input().split())
    ab[a-1].append(b)

def func(p, now):
    global res
    res[p-1]+=px[p-1]+now
    for i in ab[p-1]:
        func(i, res[p-1])


px=[0]*n
for _ in range(q):
    p,x=map(int, input().split())    
    px[p-1]+=x

res=[0]*n

func(1, 0)

print(" ".join(map(str, res)))


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

n,q=map(int, input().split())
ab=[]
for _ in range(n):
    ab.append([])
for _ in range(n-1):
    a,b=map(int, input().split())
    ab[a-1].append(b)
px=[0]*n
for _ in range(q):
    p,x=map(int, input().split())    
    px[p-1]+=x

def func(p, now):
    global res
    res[p-1]+=px[p-1]+now
    for i in ab[p-1]:
        func(i, res[p-1])

res=[0]*n

func(1, 0)

print(" ".join(map(str, res)))
### BUGGY CODE ###

import fractions
import sys
input = sys.stdin.readline


def main():
    def lcm(x, y):
        return (x * y) // fractions.gcd(x, y)

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


if __name__ == '__main__':
    main()


### FIXED CODE ###

import fractions


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


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

import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n=input()
hoge=list(map(int,input().split()))
tmp=lcm_list(hoge)
ans=0
mod=10**9+7
for i in hoge:
    ans+=tmp//i
    ans%=mod
ans%=mod
print(ans)

### FIXED CODE ###

import fractions
from functools import reduce
mod=10**9+7
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


P = 10**9 + 7
N = 10000
inv_t = [0]+[1]
for i in range(2,10**6+1):
  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]
n=input()
hoge=list(map(int,input().split()))
#hoge=[i for i in range(1,10**4)]
ans=0
l=lcm_list(hoge)%mod
for i in hoge:
    tmp=l*inv_t[i]
    ans+=tmp
    ans%=mod
ans%=mod
print(ans)
### BUGGY CODE ###

from itertools import product

n = int(input())
tops = list(map(int, input().split()))
mids = list(map(int, input().split()))
bottoms = list(map(int, input().split()))

max_mids = max(mids)
max_bottoms = max(bottoms)

tops = [t for t in tops if t < max_mids]
mids = [m for m in mids if m < max_bottoms]

sets = []

for t,m,b in product(tops,mids,bottoms):
    if t < m and m < b:
        sets.append((t,m,b))

print(len(sets))

### FIXED CODE ###

import bisect

n = int(input())
tops = list(map(int, input().split()))
mids = list(map(int, input().split()))
bottoms = list(map(int, input().split()))

tops.sort()
bottoms.sort()

nos_sets = 0

for m in mids:
    t = bisect.bisect_left(tops, m)
    b = n - bisect.bisect_right(bottoms, m)
    nos_sets += t * b

print(nos_sets)
### BUGGY CODE ###

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

for i in range(1, n +1):
    print(a.count(i))

### FIXED CODE ###

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

result = [0 for _ in range(n)]
for i in range(n - 1):
    result[a[i]-1] += 1

for v in result:
    print(v)
### BUGGY CODE ###

n = int(input())
combination_count = 0
s = []
for _ in range(n):
    si = sorted(input())
    combination_count += sum(1 for old_si in s if old_si == si)
    s.append(si)

print(combination_count)


### FIXED CODE ###

import collections

n = int(input())
counter = collections.Counter(str(sorted(input())) for _ in range(n))
combination_count = sum((v - 1) * v // 2 for v in counter.values())

print(combination_count)
### BUGGY CODE ###

n, m = list(map(int, input().split()))
#b = list(map(int, input().split()))
dic = {}
for i in range(m):
    l, r = [int(j) for j in input().split()]
    for j in range(l, r+1):
        if str(j) in dic:
            dic[str(j)] += 1
        else:
            dic[str(j)] = 1

count = 0
for i in dic.values():
    if i == m:
        count += 1

print(count)


### FIXED CODE ###

n, m = list(map(int, input().split()))
#b = list(map(int, input().split()))
l = []
r = []
for i in range(m):
    x, y = list(map(int, input().split()))
    l.append(x)
    r.append(y)
L = l[0]
R = r[0]
# print("--------")
for i in range(1, m):
    if not((R < l[i] and R < r[i]) or (r[i] < L and l[i] < L)):
        L = max(L, l[i])
        R = min(R, r[i])
    else:
        print(0)
        exit()
    #print(L, R)

print(R-L+1)
### BUGGY CODE ###

def calc(n):
  return (n+1)/2.0

N,K=map(int,input().split())
P=list(map(int,input().split()))
Q=[]
for i in P:
    Q.append(calc(i))

cnt=0.0
for i in range(N-K+1):
  S=sum(Q[i:i+K])
  cnt=max(cnt,S)

print(cnt)

### FIXED CODE ###

import numpy as np
N,K=map(int,input().split())
P=list(map(int,input().split()))
Q=[0]
def ex(A):
  return (1+A)/2.0
for i in range(N):
  Q.append(ex(P[i]))
Q=np.array(Q)
R=Q.cumsum()
ans=0
for i in range(K,N+1):
  S=R[i]-R[i-K]
  if ans<S:
    ans=S
print(ans)
### BUGGY CODE ###

import sys
import collections
import heapq
input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    AB = []
    for _ in range(N):
        a, b = map(int, input().split())
        AB.append((a, b))
    AB.sort(key=lambda x: x[0])

    H = []
    I = 0
    ans = 0
    for m in range(M):
        for i in range(I, N):
            if AB[i][0] <= m+1:
                heapq.heappush(H, -AB[i][1])
                I += 1
        if H:
            ans += -heapq.heappop(H)
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import collections
import heapq
input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    AB = []
    for _ in range(N):
        a, b = map(int, input().split())
        AB.append((a, b))
    AB.sort(key=lambda x: x[0])

    H = []
    I = 0
    ans = 0
    for m in range(M):
        for i in range(I, N):
            if AB[i][0] <= m+1:
                heapq.heappush(H, -AB[i][1])
                I += 1
            else:
                break
        if H:
            ans += -heapq.heappop(H)
    print(ans)


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

from collections import deque


def bfs(S):  # 幅優先探索  # キュー
    que, frag = deque(), set()
    for i, Si in enumerate(S):
        for j, Sij in enumerate(Si):
            if Sij == '#':
                que.append((i, j, 0)), frag.add((i, j))

    while len(que) > 0:
        (x, y, d) = que.popleft()
        near = [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)]
        for i, j in near:  # 移動先の候補
            if (i, j) in frag:  # 処理済みか否か
                continue
            if 0 <= i < h and 0 <= j < w:
                que.append((i, j, d + 1)), frag.add((i, j))
    return d


h, w = map(int, input().split())
a = [input() for _ in range(h)]
print(bfs(a))


### FIXED CODE ###

from collections import deque


def bfs(S):  # 幅優先探索  # キュー
    dist = [[-1] * w for _ in range(h)]  # 前処理
    que = deque()
    for i, Si in enumerate(S):
        for j, Sij in enumerate(Si):
            if Sij == '#':
                dist[i][j] = 0
                que.append((i, j))

    while len(que) > 0:
        (x, y) = que.popleft()
        near = [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)]
        for i, j in near:  # 移動先の候補
            if 0 <= i < h and 0 <= j < w and dist[i][j] < 0:
                dist[i][j] = dist[x][y] + 1
                que.append((i, j))
    return dist[x][y]


h, w = map(int, input().split())
a = [input() for _ in range(h)]
print(bfs(a))
### BUGGY CODE ###

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

for i in range(K):
    imos = [0] * (N + 1)
    for j in range(N):
        s = A[j]
        l, r = max(0, j - A[j]), min(j + A[j], N - 1)
        # print("l,r,s = {} {} {}".format(l, r, s))
        imos[l] += 1
        imos[r + 1] -= 1
    for k in range(N):
        imos[k + 1] = imos[k] + imos[k + 1]
    A = imos[:N]


print(*imos[:N])


### FIXED CODE ###

import sys


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    for i in range(K):
        imos = [0] * (N + 1)
        for j in range(N):
            # s = A[j]
            l, r = max(0, j - A[j]), min(j + A[j], N - 1)
            # print("l,r,s = {} {} {}".format(l, r, s))
            imos[l] += 1
            imos[r + 1] -= 1
        for k in range(N):
            imos[k + 1] = imos[k] + imos[k + 1]
        A = imos[:N]
        if A.count(N) == N:
            print(*A)
            sys.exit()

    print(*imos[:N])


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

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

K = INT()

tmp = 7
ans = 1
p = 1
mo = tmp % K
checked = [0] *  (10 ** 6 + 1)
checked[mo] = 1

while mo != 0:
    mo = mo + 7 * pow(10, p, K)
    mo %= K
    p += 1
    if checked[mo]:
        # 0には一生辿り着かない
        print(-1)
        break
    checked[mo] = 1
else:
    print(p)


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

K = INT()

tmp = 7
ans = 1
p = 1
mo = tmp % K
checked = [0] *  (10 ** 6 + 1)
checked[mo] = 1

while mo != 0:
    mo = mo + 7 * pow(10, p, K)
    mo %= K
    p += 1
    if checked[mo]:
        # 0には一生辿り着かない
        print(-1)
        break
    checked[mo] = 1
else:
    print(p)
### BUGGY CODE ###

# E - Two Currencies

n, m, s = map(int, input().split())
edge = []
for i in range(m):
    u, v, a, b = map(int, input().split())
    edge.append((u, v, a, b)) # from, to, 料金, 時間
exch = {}
for u in range(1, n+1):
    c, d = map(int, input().split())
    exch[u] = (c, d) # レート, 時間

# 料金の総和
max_silver = sum(a for u, v, a, b in edge)
s = min(s, max_silver) # max_silverまでで十分

# (都市,銀貨)を頂点とする最短経路問題
# Bellman-Ford
dist = {(1, s): 0}
for i in range(n * max_silver):
    for e in edge:
        u, v, a, b = e
        for sil in range(a, max_silver+1):
            xsil = sil - a
            if (u, sil) in dist:
                if (v, xsil) not in dist or \
                    dist[(v, xsil)] > dist[(u, sil)] + b:
                    dist[(v, xsil)] = dist[(u, sil)] + b
            if (v, sil) in dist:
                if (u, xsil) not in dist or \
                    dist[(u, xsil)] > dist[(v, sil)] + b:
                    dist[(u, xsil)] = dist[(v, sil)] + b
    for u in range(1, n+1):
        for sil in range(0, max_silver+1):
            c, d = exch[u]
            xsil = min(sil + c, max_silver)
            if (u, sil) in dist:
                if (u, xsil) not in dist or \
                    dist[(u, xsil)] > dist[(u, sil)] + d:
                    dist[(u, xsil)] = dist[(u, sil)] + d

for u in range(2, n+1):
    x = min(dist[(u, sil)] for sil in range(0, max_silver+1)
            if (u, sil) in dist)
    print(x)


### FIXED CODE ###

# E - Two Currencies

import heapq

n, m, s = map(int, input().split())
adj = {u: [] for u in range(1, n+1)}
max_silver = 0
for i in range(m):
    u, v, a, b = map(int, input().split())
    adj[u].append((v, a, b)) # to, 料金, 時間
    adj[v].append((u, a, b)) # to, 料金, 時間
    max_silver += a # 全路線の料金の総和 (これ以上は不要)
exch = {}
for u in range(1, n+1):
    c, d = map(int, input().split())
    exch[u] = (c, d) # レート, 時間

s = min(s, max_silver) # max_silverまでで十分

# n <= 50, m <= 100, max_silver <= 5000

# (都市,所有銀貨)を頂点とする最短経路問題
# Dijkstra
dist = {(1, s): 0}  # 開始頂点のみ距離0
queue = [(0, 1, s)]
dmin = {1: 0} # dmin[u] = min(dist[(u, si)] for si)
nfin = 1      # 距離が決まった都市数

while len(queue) > 0:
    di, u, si = heapq.heappop(queue)
    # 用済みのデータ
    if (u, si) in dist and di > dist[(u, si)]:
        continue
    # 都市uの距離を保存
    if u not in dmin:
        dmin[u] = di
        nfin += 1
        if nfin >= n:  # 全都市の距離が決まった
            break
    # uから直接行ける各都市について
    for v, a, b in adj[u]:
        if si < a:  # 銀貨不足
            continue
        xsi = si - a
        if (v, xsi) not in dist or \
            dist[(v, xsi)] > di + b:
            dist[(v, xsi)] = di + b
            heapq.heappush(queue, (di + b, v, xsi))
    # 両替による遷移
    c, d = exch[u]
    xsi = min(si + c, max_silver)
    if (u, xsi) not in dist or \
        dist[(u, xsi)] > di + d:
        dist[(u, xsi)] = di + d
        heapq.heappush(queue, (di + d, u, xsi))

for u in range(2, n+1):
    print(dmin[u])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(500000) 
input = sys.stdin.readline
from collections import deque
H,W = map(int,input().split())
C = list(map(int,input().split()))
C[0] -= 1; C[1] -= 1
D = list(map(int,input().split()))
D[0] -= 1; D[1] -= 1
S = []; INF = float("inf")
for i in range(H):
  temp = str(input());temp =list(temp)
  S.append(temp)
#print(S)
reach = [[INF]*W for _ in range(H)]
reach[C[0]][C[1]] = 0
dxdy = [(1,0),(-1,0),(0,1),(0,-1)]
Q = deque([])
Q.append([C,0])
while Q:
  z, score = Q.popleft()
  x = z[0];y=z[1]

  for i in range(4):
    nx = x + dxdy[i][0]
    ny = y + dxdy[i][1]
    #print(nx,ny)
    if 0<=nx<H and 0<=ny<W and S[nx][ny] == "." and reach[nx][ny] > score:
      reach[nx][ny] = min(score,reach[nx][ny])
      u = [nx,ny]
      Q.append([u,score])
  #print(reach)

  for i in range(5): #0~4
    for j in range(5):
      mx = x-2 + i
      my = y-2 + j
      if i == 2 and j == 2:
        continue
      if mx < 0 or mx >= H or my < 0 or my >= W or S[mx][my] == "#":
        continue
      if reach[mx][my] <= score+1: #すでにこのスコア以下でいける。
        continue
      reach[mx][my] = min(score+1,reach[mx][my])
      p = [mx,my]
      #print(v,p,"X")
      Q.append([p,score+1])
#dfs(C,0)
#print(reach)
#print(reach[D[0]][D[1]])
if reach[D[0]][D[1]] == INF:
  print(-1)
else:
  print(reach[D[0]][D[1]])

### FIXED CODE ###

import sys
sys.setrecursionlimit(500000) 
input = sys.stdin.readline
from collections import deque
H,W = map(int,input().split())
C = list(map(int,input().split()))
C[0] -= 1; C[1] -= 1
D = list(map(int,input().split()))
D[0] -= 1; D[1] -= 1
S = []; INF = float("inf")
for i in range(H):
  temp = str(input());temp =list(temp)
  S.append(temp)
#print(S)
reach = [[INF]*W for _ in range(H)]
reach[C[0]][C[1]] = 0
dxdy = [(1,0),(-1,0),(0,1),(0,-1)]
Q = deque([])
Q.append([C,0])
while Q:
  z, score = Q.popleft()
  x = z[0];y=z[1]
 
  for i in range(4):
    nx = x + dxdy[i][0]
    ny = y + dxdy[i][1]
    #print(nx,ny)
    if 0<=nx<H and 0<=ny<W and S[nx][ny] == "." and reach[nx][ny] > score:
      reach[nx][ny] = min(score,reach[nx][ny])
      u = [nx,ny]
      Q.appendleft([u,score])
  #print(reach)
 
  for i in range(5): #0~4
    for j in range(5):
      mx = x-2 + i
      my = y-2 + j
      if i == 2 and j == 2:
        continue
      if mx < 0 or mx >= H or my < 0 or my >= W or S[mx][my] == "#":
        continue
      if reach[mx][my] <= score+1: #すでにこのスコア以下でいける。
        continue
      reach[mx][my] = min(score+1,reach[mx][my])
      p = [mx,my]
      #print(v,p,"X")
      Q.append([p,score+1])
#dfs(C,0)
#print(reach)
#print(reach[D[0]][D[1]])
if reach[D[0]][D[1]] == INF:
  print(-1)
else:
  print(reach[D[0]][D[1]])
### BUGGY CODE ###

from bisect import bisect_left, bisect_right

# def lower_bound(L, v):
#     # [ok, ng) - Maximum
#     # (ng, ok] - Minimum
#     # ok が 最終的な答え
#     ok = N
#     ng = -1
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if L[mid] >= v:
#             ok = mid
#         else:
#             ng = mid
#     return ok


# def upper_bound(L, v):
#     # [ok, ng) - Maximum
#     # (ng, ok] - Minimum
#     # ok が 最終的な答え
#     ok = -1
#     ng = N
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if L[mid] < v:
#             ok = mid
#         else:
#             ng = mid
#     return ok


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A.sort()
B.sort()
M = A[-1] + B[-1]
K = len(bin(M)) - 2
mask = (1 << K) - 1
bit = [0] * K
k = K - 1
while M > 0:
    T = 1 << k
    B = [x & mask for x in B]
    B.sort()
    for a in A:
        a_ = a & mask
        T1 = bisect_left(B, T - a_)
        T2 = bisect_left(B, 2 * T - a_)
        T3 = bisect_left(B, 3 * T - a_)
        T4 = bisect_left(B, 4 * T - a_)
        bit[k] += (T4 - T3) + (T2 - T1)
        bit[k] %= 2
    M >>= 1
    k -= 1
    mask >>= 1

result = 0
for i, k in enumerate(bit):
    result += k * (1 << i)

print(result)


### FIXED CODE ###

def solve():
    # from bisect import bisect_left
    import sys

    N = int(input())
    A = [int(x) for x in sys.stdin.readline().split()]
    B = [int(x) for x in sys.stdin.readline().split()]
    M = max(A) + max(B)
    K = len(bin(M)) - 2
    mask = (1 << K) - 1
    k = K - 1
    T = 1 << k
    ans = 0
    while k >= 0:
        for i in range(N):
            B[i] &= mask
            A[i] &= mask
        B = list(sorted(b & mask for b in B))
        A = list(sorted(a & mask for a in A))
        bit = 0
        T1, T2, T3 = 0, 0, 0
        for a in reversed(A):
            while T1 < N and a + B[T1] < T:
                T1 += 1
            while T2 < N and a + B[T2] < 2 * T:
                T2 += 1
            while T3 < N and a + B[T3] < 3 * T:
                T3 += 1
            # T1 = bisect_left(B, T - a, T1)
            # T2 = bisect_left(B, 2 * T - a, T2)
            # T3 = bisect_left(B, 3 * T - a, T3)
            # T4 = bisect_left(B, 4 * T - a, T4)
            bit += (N - T3) + (T2 - T1)
            bit &= 1
        ans += bit * T
        k -= 1
        T >>= 1
        mask >>= 1

    print(ans)


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

K = int(input())
ans = -1
if K in [2,5]:
    pass
else:
    num = 7
    ans = 0
    while True:
        ans += 1
        if num % K == 0:
            break
        else:
            num = (num * 10 + 7)%K
print(ans)

### FIXED CODE ###

K = int(input())
ans = -1
if K%2 == 0:
    pass
elif K%5 == 0:
    pass
else:
    num = 7
    ans = 0
    while True:
        ans += 1
        if num % K == 0:
            break
        else:
            num = (num * 10 + 7)%K
print(ans)
### BUGGY CODE ###

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
B = list(map(int, input().split()))
B.sort(reverse=True)
C = list(map(int, input().split()))
C.sort(reverse=True)
# A = sorted(list(map(int, input().split())), reverse=True)
# B = sorted(list(map(int, input().split())), reverse=True)
# C = sorted(list(map(int, input().split())), reverse=True)

AB = []
ABC = []
for b in B:
    for a in A:
        AB.append(a+b)
AB.sort(reverse=True)
AB = AB[:K]
# AB = AB[:min(3001, X*Y*Z+1)]

for c in C:
    for ab in AB:
        ABC.append(ab+c)
ABC.sort(reverse=True)
for i in range(K):
    print(ABC[i])

### FIXED CODE ###

x,y,z,k = map(int,input().split())
lisa = list(map(int,input().split()))
lisb = list(map(int,input().split()))
lisc = list(map(int,input().split()))
lisa.sort(reverse=True)
lisb.sort(reverse=True)
lisc.sort(reverse=True)
an = []
ans = []
for num in lisb:
    for nu in lisa:
        an.append(num+nu)
an.sort(reverse=True)
an = an[:min(3001,x*y*z+1)]
for num in lisc:
    for nu in an:
        ans.append(num+nu)
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])
### BUGGY CODE ###

k = int(input())
m = 7
if(k%2==0):
  print("-1")
else:
  i = 1
  while True:
    j = m%k
    if(j==0):
      print(i)
      break  
    if(i>1000000):
      print("-1")
      break
    m *= 10
    m += 7
    i += 1



### FIXED CODE ###

k = int(input())
m = 7
if(k%2==0):
  print("-1")
else:
  i = 1
  while True:
    m = m%k
    if(m==0):
      print(i)
      break  
    if(i>k):
      print("-1")
      break
    m *= 10
    m += 7
    i += 1