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

import numpy as np
import itertools
import bisect

n=int(input())
a=sorted([int(i) for i in input().split()])
b=sorted([int(i) for i in input().split()])
c=sorted([int(i) for i in input().split()])

count=0
index_b=0
index_c=0
for i in range(n):
        index_c=bisect.bisect_left(b,c[i])
        for j in range(index_c):
                count+=bisect.bisect_left(a,b[j])
print(count)

### FIXED CODE ###

import numpy as np
import bisect

n=int(input())
a=sorted([int(i) for i in input().split()])
b=sorted([int(i) for i in input().split()])
c=sorted([int(i) for i in input().split()])

count=0
index_b=0
index_c=0
count_b=[0]*(n+1)
for i in range(n):
        count_b[i+1]=bisect.bisect_left(a,b[i])+count_b[i]
for i in range(n):
        count+=count_b[bisect.bisect_left(b,c[i])]
print(count)
### BUGGY CODE ###

n,k = map(int,input().split())
a = tuple(map(int,input().split()))
mod = 10**9+7
rng = 1001
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
  if n<0 or k<0:
    return 0
  else:
    return fctr[n]*finv[n-k]*finv[k]%mod
dp = [[0 for i in range(n+1)] for j in range(k+1)]
dp[0][0] = 1
for i in range(1,k+1):
  x = a[i-1]
  for j in range(n+1):
    for t in range(min(n-j,x)+1):
      dp[i][j+t]=(dp[i][j+t]+dp[i-1][j]*cmb(n-j,t)*cmb(n-t,x-t))%mod
print(dp[k][n])

### FIXED CODE ###

n,k = map(int,input().split())
a = tuple(map(int,input().split()))
mod = 10**9+7
rng = 1001
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
  finv.append(pow(fctr[i],mod-2,mod))
dp = [[0 for i in range(n+1)] for j in range(k+1)]
dp[0][0] = 1
for i in range(1,k+1):
  x = a[i-1]
  for j in range(n+1):
    if dp[i-1][j] == 0:
      continue
    y = dp[i-1][j]*fctr[n-j]*finv[n-x]%mod
    for t in range(min(n-j,x)+1):
      dp[i][j+t]=(dp[i][j+t]+y*fctr[n-t]*finv[n-j-t]*finv[t]*finv[x-t])%mod
print(dp[k][n])
### BUGGY CODE ###

def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

ans1 = [1 for i in range(4001)]
ans2 = [0 for i in range(4001)]
ans3 = [0 for i in range(4001)]
ans4 = [0 for i in range(4001)]

for i in range(1001):
    ans1[i] = 1
for i in range(1001,4001):
    ans1[i] = 0

for i in range(4001):
    for j in range(i+1):
        ans2[i] += ans1[j]

for i in range(4001):
    for j in range(i+1):
        ans3[i] += ans2[j]

for i in range(4001):
    for j in range(i+1):
        ans4[i] += ans3[j]

N = list(get_input())
for l in range(len(N)):
    print(ans4[int(N[l])])



### FIXED CODE ###

def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

ans1 = [0 for i in range(4001)]
ans2 = [0 for i in range(4001)]
ans3 = [0 for i in range(4001)]
ans4 = [0 for i in range(4001)]

for i in range(1001):
    ans1[i] = 1
for i in range(1001,4001):
    ans1[i] = 0

for i in range(4001):
    for j in range(1001):
        ans2[i] += ans1[i-j]

for i in range(4001):
    for j in range(1001):
        ans3[i] += ans2[i-j]

for i in range(4001):
    for j in range(1001):
        ans4[i] += ans3[i-j]

#print("DONE")
N = list(get_input())
for l in range(len(N)):
    print(ans4[int(N[l])])
### BUGGY CODE ###

from math import *



N,K = tuple(map(int,input().split()))
groupId_V = [v for v in range(N)]
vs_groupId = {v:[v] for v in range(N)}

for _ in range(K):
    u,v,w = tuple(map(int,input().split()))
    u-=1
    v-=1
    uGroupId = groupId_V[u]
    vGroupId = groupId_V[v]
    if uGroupId==vGroupId:
        continue
    uFriends = vs_groupId[uGroupId]
    vFriends = vs_groupId[vGroupId]
    for vFriend in vFriends:
        groupId_V[vFriend] = uGroupId
    vs_groupId[vGroupId] = []
    vs_groupId[uGroupId] = uFriends+vFriends

re = 0
for vs in vs_groupId.values():
    if len(vs) != 0:
        re += 1

print(re)


### FIXED CODE ###

from math import *



class V:
    def __init__(self,si):
        self.si = si
        self.parent = self
    def isInnovator(self):
        return self.parent == self
    def findInnovator(self):
        re = self
        while True:
            if re.parent == re:
                self.parent = re
                return re
            re = re.parent


N,K = tuple(map(int,input().split()))
vs = [V(vi) for vi in range(N)]

for _ in range(K):
    ui,vi,w = tuple(map(int,input().split()))
    ui-=1
    vi-=1
    u = vs[ui]
    v = vs[vi]
    uInnov = u.findInnovator()
    vInnov = v.findInnovator()
    if uInnov == vInnov:
        continue
    vInnov.parent = uInnov

re = 0
for v in vs:
    if v.isInnovator():
        re += 1

print(re)
### BUGGY CODE ###

S = input()
Q = int(input())
s = list(S)

for i in range(Q):
    query = input()
    ti = list(query)[0]
    if ti == '1':
        s.reverse()
    else:
        ti, fi, ci = query.split()
        if fi == '1':
            s = list(ci) + s
        else:
            s = s + list(ci)
print(''.join(s))

### FIXED CODE ###

class Node:
    def __init__(self, char: str):
        self.before = None
        self.char = char
        self.next = None

class Linked_List:
    def __init__(self):
        self.head = None
        self.tail = None
    
    def add_head(self, node):
        if self.head is None:
            self.head = node
            self.tail = node
        else:
            node.next = self.head
            self.head.before = node
            self.head = node

    def add_tail(self, node):
        if self.tail is None:
            self.head = node
            self.tail = node
        else:
            node.before = self.tail
            self.tail.next = node
            self.tail = node

    def show(self, is_reversed: bool):
        ret = []
        node = self.tail if is_reversed else self.head
        while not node is None:
            c = ''.join(list(node.char)[::-1]) if is_reversed else node.char
            ret.append(c)
            node = node.before if is_reversed else node.next
        print(''.join(ret))

S = input()
Q = int(input())
ll = Linked_List()
ll.add_head(Node(S))
is_reversed = False

for _ in range(Q):
    query = input()
    if query[0] == '1':
        is_reversed = False if is_reversed else True
    else:
        t, f, c = query.split()
        if is_reversed:
            c = ''.join(list(c)[::-1])
        if f == '1':
            if is_reversed:
                ll.add_tail(Node(c))
            else:
                ll.add_head(Node(c))
        else:
            if is_reversed:
                ll.add_head(Node(c))
            else:
                ll.add_tail(Node(c))

ll.show(is_reversed)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n=int(input())
a = list(map(int,input().split()))
cnt = [0,0,0] #1個の個数、二個の個数、三個の個数
for i in range(n):
    cnt[a[i]-1] += 1
    
def f(i,j,k):
    if [i,j,k] == [0,0,0]:
        return 0.0
    if dp[i][j][k] != 0.0:
        return dp[i][j][k]
    tmp = 0.0
    if i>0:
        tmp += f(i-1,j,k)*float(i)/float(i+j+k)
    if j>0:
        tmp += f(i+1,j-1,k)*float(j)/float(i+j+k)
    if k>0:
        tmp += f(i,j+1,k-1)*float(k)/float(i+j+k)
    tmp += float(n)/float(i+j+k)
    
 
    dp[i][j][k] = tmp
    return tmp

dp = [[[0.0 for i in range(n+1)] for j in range(n+1)] for k in range(n+1)]
 
print(f(cnt[0],cnt[1],cnt[2]))

### FIXED CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = tuple(map(int,input().split()))
c1 = a.count(1)
c2 = a.count(2)
c3 = a.count(3)

dp = [[[0.0]*(n+1) for i in range(n+1)] for j in range(n+1)] 
dp[0][0][0] = 0
for i in range(c3+1):
    for j in range(c2+c3-i+1):
        for k in range(n-i-j+1):
            if i == j == k == 0:
                continue
            tmp = n
            if k != 0:
                tmp += k*dp[k-1][j][i]
            if j != 0:
                tmp += j*dp[k+1][j-1][i]
            if i != 0:
                tmp += i*dp[k][j+1][i-1]
            dp[k][j][i] = tmp/(i+j+k)

print(dp[c1][c2][c3])
### BUGGY CODE ###

N,M = map(int,input().split())

l,r = map(int,input().split())
Kouho = [int(i) for i in range(l,r+1)]
for i in range(M-1):
    l,r = map(int,input().split())
    tmp = [int(i) for i in range(l,r+1)]
    for j in Kouho[:]:
        if not j in tmp:
            Kouho.remove(j)

   
print(len(Kouho))


### FIXED CODE ###

N,M = map(int,input().split())
Max_l = 0
Min_r = float('inf')

for i in range(M):
    l,r = map(int,input().split())
    Max_l = max(Max_l,l)
    Min_r = min(Min_r,r)
ans = 0
if Max_l<=Min_r:
    ans = Min_r-Max_l+1
    

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

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

for a in A:
  if a == 0:
    prod == 0

for a in A:
  prod *= a

if prod > 10**18:
  prod = -1

print(prod) 

### FIXED CODE ###

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

  for a in A:
    if a == 0:
      print(0)
      return

  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return

  print(prod) 

main()
### BUGGY CODE ###

from sys import stdin


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

    _in = [_.rstrip() for _ in stdin.readlines()]
    S =     _in[0]   # type:str
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    len_S = len(S)
    cnt = 0
    mod_arr = [0 for i in range(2019)]
    mod_arr[0] += 1
    for i in range(0,len_S+1):
        _ = int(S[len_S-i-1:])
        if i>0: mod = (mod+int(S[len_S-i-1])*10**i)%2019
        else:   mod = _%2019
        mod_arr[mod]+=1
    for i in range(2019):
        if mod_arr[i] > 0:
            cnt += mod_arr[i]*(mod_arr[i]-1)//2
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


### FIXED CODE ###

from sys import stdin


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    S =     _in[0]   # type:str
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    len_S = len(S)
    cnt = 0
    for i in range(len_S):
        for j in range(i+3,len_S):
            if j == i+3:
                mod = int(S[len_S-j-1:len_S-i])%3
            else:
                mod = (mod+int(S[len_S-j-1]))%3
            if mod == 0:
                _ = int(S[len_S-j-1:len_S-i])
                if _%673==0:
                    cnt += 1
                    break
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


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

    _in = [_.rstrip() for _ in stdin.readlines()]
    S =     _in[0]   # type:str
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = 0
    mod_arr = [0] * 2019
    mod_arr[0] += 1

    num, dec = 0, 1
    for s in S[::-1]:
        num += int(s)*dec
        num %= 2019
        dec *= 10
        dec %= 2019
        mod_arr[num] += 1

    for i in range(2019):
        if mod_arr[i] > 0:
            cnt += mod_arr[i]*(mod_arr[i]-1)//2
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)
### BUGGY CODE ###

n=int(input())+1
a=0
for i in range(1,n):
  for j in range(i,n,i):a+=j
print(a)

### FIXED CODE ###

a=int(input())
b=(a)//2+1
ans=0
for i in range(1,b,1):
  x=a//i
  ans+=((x**2+x)//2)*i
ans+=(a**2+a+b-b**2)//2
print(ans)
### BUGGY CODE ###

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

for _ in range(Q):
    l,r = map(int, input().split())
    word = "".join(S[l-1:r])
    print(word.count("AC"))

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()

nums = [0] * N
count = 0
for i in range(len(S)-1):
    nums[i] = count
    if S[i] == "A" and S[i+1] == "C":
        count += 1
nums[-1] = count

for _ in range(Q):
    l,r = map(int, input().split())
    print(nums[r-1] - nums[l-1])
### BUGGY CODE ###

n=int(input())
l=list(map(int,input().split()))
list=[]
for ll in l:
  list.append([l.index(ll)+1,ll])
list.sort(key=lambda x:x[1])
ans=[]
for aa in list:
  ans.append(aa[0])
print(*ans)

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
list=[]
for i in range(n):
  list.append([i+1,l[i]])
list.sort(key=lambda x:x[1])
ans=[]
for aa in list:
  ans.append(aa[0])
print(*ans)
### BUGGY CODE ###

from bisect import bisect_left, insort_left
from collections import deque
import sys
readlines = sys.stdin.readline
def main():
	x,y,a,b,c = map(int,input().split())

	p = list(map(int,input().split()))
	q = list(map(int,input().split()))
	r = list(map(int,input().split()))

	p.sort()
	q.sort()
	r.sort(reverse=True)

	p = p[a-x:]
	q = q[b-y:]
	ans = sum(p) + sum(q)
	p_count = 0
	q_count = 0

	for i in range(c):
		if p[p_count] < r[i] and q[q_count] < r[i]:
			if p[p_count] < q[q_count]:
				ans -= p[p_count]
				ans += r[i]
				insort_left(p,r[i])
				p_count += 1
			else:
				ans -= q[q_count]
				ans += r[i]
				insort_left(q,r[i])
				q_count += 1
		elif p[p_count] < r[i]:
			ans -= p[p_count]
			ans += r[i]
			insort_left(p,r[i])
			p_count += 1
		elif q[q_count] < r[i]:
			ans -= q[q_count]
			ans += r[i]
			insort_left(q,r[i])
			q_count += 1
		else:
			break

	print(ans)
if __name__ == '__main__':
	main()

### FIXED CODE ###

x,y,a,b,c = map(int,input().split())

p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort()
q.sort()
r.sort(reverse=True)

p = p[a-x:]
q = q[b-y:]

p.extend(q)
p.sort()

ans = sum(p)
count = 0
for i in range(c):
	if p[i] < r[i]:
		ans += r[i] - p[i]
	else:
		break
print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())
S = []
for _ in range(K):
    l, r = map(int, input().split())
    S += [i for i in range(l, r+1)]
S.sort()
mod = 998244353

dp = [0] * (N+1)
dp[1] = 1
for i in range(1, N+1):
    for d in S:
        if i+d > N:
            break
        dp[i+d] += dp[i] % mod
print(dp[N]%mod)

### FIXED CODE ###

N, K = map(int, input().split())
S = []
for _ in range(K):
    l, r = map(int, input().split())
    S.append((l, r))

mod = 998244353
 
dp = [0] * (N+1)
cumsum_dp = [0] * (N+1)
dp[1] = 1
cumsum_dp[1] = 1

for i in range(2, N+1):
    for s in S:
        fr = max(0, i-s[1]-1)
        to = max(0, i-s[0])
        dp[i] += (cumsum_dp[to]-cumsum_dp[fr]) % mod
    cumsum_dp[i] = (cumsum_dp[i-1] + dp[i]) % mod
    
print(dp[N]%mod)
### BUGGY CODE ###

from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
import math


#N,K=map(int,input().split())
N=int(input())
S=input()
Q=int(input())


def segfunc(x,y):
    return (x|y)

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2])

def update(k,b):
    k += num-1
    if seg[k]==set([b]):
        return ()
    seg[k] = set([b])
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
def subquery(l, r, k, i, j):
        # 区間[i,j)の中で区間[l,r)の文字列の集合を返す
        if j <= l or r <= i:
            return set()
        elif l <= i and j <= r:
            return seg[k]
        else:
            l_set = subquery(l, r, 2 * k + 1, i, (i + j) // 2)
            r_set = subquery(l, r, 2 * k + 2, (i + j) // 2, j)
            return l_set | r_set

def query(l, r):
    # [l,r)に含まれる文字の種類数
    return len(subquery(l, r, 0, 0, num))
ide_ele =set()

#num:n以上の最小の2のべき乗
n=N
num =2**(n-1).bit_length()
seg=[set() for i in range(2*num)]

for i in range(N):
    update(i,ord(S[i]))

for q in range(Q):
    type, i, c = input().split()
    if type=="1":
        update(int(i)-1,ord(c))
    else:
        print(query(int(i)-1,int(c)))
    #print(seg)


### FIXED CODE ###

from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
import math


#N,K=map(int,input().split())
N=int(input())
S=input()
Q=int(input())
Query=[input().split() for i in range(Q)]

def segfunc(x,y):
    return (x|y)

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=seg[2*i+1]|seg[2*i+2]

def update(k,b):
    k += num-1
    if seg[k]=={b}:
        return ()
    seg[k] = {b}
    while k:
        k = (k-1)>>1
        seg[k] = seg[k*2+1]|seg[k*2+2]

def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=set()
    while q-p>1:
        if p&1 == 0:
            res = res|seg[p]
        if q&1 == 1:
            res = res|seg[q]
            q -= 1
        p = p>>1
        q = (q-1)>>1
    if p == q:
        res = res|seg[p]
    else:
        res = res|seg[p]|seg[q]
    return res

#num:n以上の最小の2のべき乗
n=N
num =2**(n-1).bit_length()
seg=[set()] * (2*num)

for i in range(N):
    seg[i+num-1]={ord(S[i])}
for k in range(num-2,-1,-1):
    seg[k] = seg[k*2+1]|seg[k*2+2]
for type, i, c in Query:
    if type=="1":
        update(int(i)-1,ord(c))
    else:
        print(len(query(int(i)-1,int(c))))
    #print(seg)
### BUGGY CODE ###

import copy
import bisect
#from statistics import median


N = int(input())

X = input().split()
X = [ int(x) for x in X]
"""
N = 4
X = [2,4,4,3]
"""
j = int(N/2)
F = copy.deepcopy(X)
F.sort()


for i in range(N):
    S = copy.deepcopy(F)
#    print(S)
    #print(bisect.bisect_left(S, X[i]))
    del S[bisect.bisect_left(S, X[i])]
#    print(S)
    print(S[j-1])
    

### FIXED CODE ###

from statistics import median, median_low, median_high


N = int(input())

X = input().split()
X = [ int(x) for x in X]
"""
N = 4
X = [2,4,4,3]
"""
median = median(X)
#F = copy.deepcopy(X)
"""
F = X[:]
F.sort()

median1 = int(N/2 - 1)
median2 = int(N/2) 

if median.is_integer():
    median1 = median
    median2 = median
else:
    median1 = median - 0.5
    median2 = median + 0.5
"""
median1 = median_low(X)
median2 = median_high(X)
   
for i in range(N):
    #print(F, median1, median2)
    
    if X[i] < median:
        ans = median2
    else:
        ans = median1
    print(int(ans))
### BUGGY CODE ###

from itertools import accumulate
n=int(input())
A=sorted([int(i) for i in input().split()])
B=sorted([int(i) for i in input().split()])
C=sorted([int(i) for i in input().split()])
a=[]
b=[]
for i in range(n):
    for j in range(n):
        if A[i]<B[j]:
            a.append(n-j)
            break
    else:
        a.append(0)
for i in range(n):
    for j in range(n):
        if B[i]<C[j]:
            b.append(n-j)
            break
    else:
        b.append(0)
b.sort()
b=list(accumulate(b))
ans=0
for i in range(n):
    if a[i]!=0:
        ans+=b[a[i]-1]
print(ans)

### FIXED CODE ###

import bisect
n=int(input())
abc=[sorted(list(int(i) for i in input().split())) for i in range(3)]
print(sum([bisect.bisect_left(abc[0],b)*(n-bisect.bisect_right(abc[2],b)) for b in abc[1]]))
### BUGGY CODE ###

s = int(input())

for x in range(0, 10**9):
  for y in range(x, -1, -1):
    t = s - x*y
    if t <= 0:
      break
    if t - int(t) == 0:
      if t % 2 == 0 and t / 2 <= 10**9:
        if abs(x*y - t) != s:
            continue
        print('{0} {1} {2} {3} {4} {5}'.format(0, 0, x, 2, t//2, y))
        quit()
      else:
        for i in range(1, 10**9, 2):
          if t % i == 0 and t // i <= 10**9:
            if abs(x*y - t) != s:
                continue
            print('{0} {1} {2} {3} {4} {5}'.format(0, 0, x, i, t//i, y))
            quit()

### FIXED CODE ###

s = int(input())

a = s // 10**9 + 1
b = 10**9 - s % 10**9
if a > 10**9:
  a -= 1
  b -= 10**9

assert abs(a * 10**9 - b) == s

print(" ".join(map(str, [0, 0, a, 1, b, 10**9])))
### BUGGY CODE ###

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

gK=[set([x]) for x in range(N)]
gL=[set([x]) for x in range(N)]

class UnionFind(object):
  def __init__(self,n):
    self.table=[-1]*n
 
  def find(self,x):
    parent=self.table[x]
    if parent<0:
      return x
    else:
      root=self.find(parent)
      self.table[x]=root
      return root
 
  def union(self,a,b,li):
    root1=self.find(a)
    root2=self.find(b)
    if root1 != root2:
      if self.table[root1] != self.table[root2]:
        if self.table[root1] < self.table[root2]:
          self.table[root2]=root1
          li[root1]=(li[root1] | li[root2])
        else:
          self.table[root1]=root2
          li[root2]=(li[root1] | li[root2])
      else:
        self.table[root1]+=(-1)
        self.table[root2]=root1
        li[root1]=(li[root1] | li[root2])
      
ufK=UnionFind(N)
for i in range(K):
  p,q=map(int,input().split())
  gK[p-1].add(q-1)
  gK[q-1].add(p-1)
  ufK.union(p-1,q-1,gK)

ufL=UnionFind(N)
for i in range(L):
  p,q=map(int,input().split())
  gL[p-1].add(q-1)
  gL[q-1].add(p-1)
  ufL.union(p-1,q-1,gL)

ans=[]
for i in range(N):
  a=ufK.find(i)
  b=ufL.find(i)
  ab= (gK[a] & gL[b])
  ans.append(len(ab))

print(*ans)


### FIXED CODE ###

from collections import defaultdict

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

class UnionFind(object):
  def __init__(self,n):
    self.table=[-1]*n
 
  def find(self,x):
    parent=self.table[x]
    if parent<0:
      return x
    else:
      root=self.find(parent)
      self.table[x]=root
      return root
 
  def union(self,a,b):
    root1=self.find(a)
    root2=self.find(b)
    if root1 != root2:
      if self.table[root1] != self.table[root2]:
        if self.table[root1] < self.table[root2]:
          self.table[root2]=root1
        else:
          self.table[root1]=root2
      else:
        self.table[root1]+=(-1)
        self.table[root2]=root1
      
ufK=UnionFind(N)
for i in range(K):
  p,q=map(int,input().split())
  ufK.union(p-1,q-1)

ufL=UnionFind(N)
for i in range(L):
  p,q=map(int,input().split())
  ufL.union(p-1,q-1)

KL=defaultdict(int)
ans=[]
for i in range(N):
  a=ufK.find(i)
  b=ufL.find(i)
  KL[(a,b)]+=1
for i in range(N):
  a=ufK.find(i)
  b=ufL.find(i)
  ans.append(KL[(a,b)])
  
print(*ans)
### BUGGY CODE ###

import numpy as np
N, K = map(int, input().split())
p_list = list(map(int, input().split()))
expect_list = np.array(p_list)
expect_list = (expect_list + 1)/2
sum_list = []
#print(expect_list)

for i in range(N-K+1):
    sum=0
    for j in range(K):
        sum += expect_list[i+j]

    sum_list.append(sum)

print(max(sum_list))

### FIXED CODE ###

import numpy as np
N, K = map(int, input().split())
p_list = list(map(int, input().split()))
expect_list = np.array(p_list)
expect_list = (expect_list + 1)/2
sum_list = []
#print(expect_list)
sum=0
for i in range(K):
    sum += expect_list[i]

sum_list.append(sum)

for i in range(1,N-K+1):
    sum -= expect_list[i-1]
    sum += expect_list[i+K-1]
    sum_list.append(sum)

print(max(sum_list))
### BUGGY CODE ###

a,b=map(int,input().split())
c=0
for i in range(40):
    j=2**i
    x,y=-(-a//(j*2))*j*2,b//(j*2)*j*2
    if x>=y:
        t=0
        for p in range(a,b+1):
            t+=p&j>0
        #print(t)
    else:
        t=(y-x)//2
        t+=min(j,x-a)
        t+=max(0,b-y-j+1)
    c+=t%2*j
print(c)

### FIXED CODE ###

a,b=map(int,input().split())
c=0
for i in range(40):
    j=2**i
    x,y=-(-a//(j*2))*j*2,b//(j*2)*j*2
    """
    if x>=y:
        t=0
        for p in range(a,b+1):
            t+=p&j>0
    else:
    """
    t=(y-x)//2
    t+=min(j,x-a)
    t+=max(0,b-y-j+1)
    c+=t%2*j
print(c)
### BUGGY CODE ###

X,Y,Z,K=map(int,input().split())
A= list(map(int,input().split()))
B= list(map(int,input().split()))
C= list(map(int,input().split()))
AB=[0]*(X*Y)
t=0
for i in A:
 for j in B:
  AB[t]=i+j
  t+=1
AB.sort(reverse=True)
ABA=AB[0:min(K,X*Y)]
D=[0]*(Z*len(ABA))
t=0
for i in ABA:
 for j in C:
  D[t]=i+j
  t+=1
D.sort(reverse=True)
for i in range(K):
 print(D[i])


### FIXED CODE ###

X,Y,Z,K=map(int,input().split())
A= list(map(int,input().split()))
B= list(map(int,input().split()))
C= list(map(int,input().split()))
AB=[0]*(X*Y)
t=0
for i in A:
 for j in B:
  AB[t]=i+j
  t+=1
AB.sort(reverse=True)
ABA=AB[0:min(K,X*Y)]
D=[0]*(Z*len(ABA))
t=0
for i in ABA:
 for j in C:
  D[t]=i+j
  t+=1
D.sort(reverse=True)
for i in range(K):
 print(D[i])
### BUGGY CODE ###

import math, itertools
from functools import reduce
def gcd_list(numbers):
    return(reduce(math.gcd,numbers))
k=int(input())
ans=0
for numbers in itertools.product(range(1,k+1),repeat=3):
    ans+=gcd_list(numbers)
print(ans)

### FIXED CODE ###

import math, itertools
from functools import reduce
def gcd_list(numbers):
    return(reduce(math.gcd,numbers))
k=int(input())
ans=0
for numbers in itertools.combinations_with_replacement(range(1,k+1),3):
    a,b,c=numbers
    if a==b==c:
        ans+=gcd_list(numbers)
    elif a!=b and a!=c and b!=c:
        ans+=6*gcd_list(numbers)
    else:
        ans+=3*gcd_list(numbers)
print(ans)