Harryxun/stf_run huggingface dataset:
# C
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
if n = 0:
    print(x)
elif x not in p:
    print(x)
else:
    for i in range(102):
        if i not in p
            if abs(x - i) < abs(x - ans):
                ans = i
    print(ans)

### FIXED CODE ###

# C
x, n = map(int, input().split())
p = list(map(int, input().split()))
# print(p)
ans = 0
if n == 0:
    print(x)
elif x not in p:
    print(x)
else:
    for i in range(102):
        if i not in p:
            if abs(x - i) < abs(x - ans):
                ans = i
    print(ans)
s,t = map(str,input.split())
a,b = map(int,input.split())
u = str(input())
if s == u:
    a -= 1
if s == u :
    b -= 1
print("{0} {1}".format(a,b))

### FIXED CODE ###

S, T = map(str,input().split())
A, B = map(int,input().split())
U = input()
 
if S == U: A -= 1
if T == U: B -= 1
print("{0} {1}".format(A,B))
n, m = map(int, input().split()))
# 偶数 ＋　奇数
print(n * (n - 1) // 2 + m * (m - 1) // 2  )

### FIXED CODE ###

n, m = list(map(int, input().split()))
# 偶数 ＋　奇数
print(n * (n - 1) // 2 + m * (m - 1) // 2  )
from collections import deque
n = input()

C = [None]*n
P = [None]*n
for i in xrange(n):
    ipt = map(int, raw_input().split())
    C[i] = ipt[1:]
    for c in C[i]:
        P[c] = i
LEV = (n+1).bit_length()
parent = [[None]*(LEV + 1) for i in xrange(n)]
for i in xrange(n):
    parent[i][0] = P[i]
for k in xrange(1, LEV):
    for i in xrange(n):
        if parent[i][k] is None:
            parent[i][k+1] = None
        else:
            parent[i][k+1] = parent[parent[i][k]][k]
depth = [None]*n
deq = deque()
deq.append(0)
depth[0] = 0
while deq:
    v = deq.popleft()
    for c in C[v]:
        deq.append(c)
        depth[c] = depth[v] + 1

q = input()
for t in xrange(q):
    u, v = map(int, raw_input().split())
    if not depth[u] < depth[v]:
        u, v = v, u
    for k in xrange(LEV+1):
        if ((depth[v] - depth[u]) >> k) & 1:
            v = parent[v][k]
    if u == v:
        print u
        continue

    for k in xrange(LEV, -1, -1):
        if parent[u][k] != parent[v][k]:
            u = parent[u][k]
            v = parent[v][k]
    print parent[u][0]

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

readline = sys.stdin.readline
write = sys.stdout.write

N = int(readline())
G = [None]*N
for v in range(N):
    k, *G[v] = map(int, readline().split())

S = []

FS = [0]*N
depth = [0]*N

*it, = map(iter, G)
P = [-1]*N

stk = [0]
depth[0] = 0
FS[0] = 0
while stk:
    v = stk[-1]
    p = P[v]
    S.append(v)

    w = next(it[v], -1)
    while w != -1:
        if w != p:
            P[w] = v
            depth[w] = len(stk)
            FS[w] = len(S)
            stk.append(w)
            break
        w = next(it[v], -1)
    else:
        stk.pop()

L = len(S)
lg = [0]*(L + 1)
for i in range(2, L+1):
    lg[i] = lg[i >> 1] + 1
st = [None]*(lg[L] + 1)
st0 = st[0] = S
b = 1
for i in range(lg[L]):
    st0 = st[i+1] = [p if depth[p] <= depth[q] else q for p, q in zip(st0, st0[b:])]
    b <<= 1

def query(u, v):
    x = FS[u]; y = FS[v]
    if x > y:
        x, y = y, x
    l = lg[y - x + 1]
    px = st[l][x]; py = st[l][y - (1 << l) + 1]
    return px if depth[px] <= depth[py] else py

Q = int(readline())
ans = []
for q in range(Q):
    u, v = map(int, readline().split())
    ans.append(query(u, v))
write("\n".join(map(str, ans)))
write("\n")
from collections import deque
n, k = map(int,input().split())
a = list(map(int,input().split()))
mod = 10 ** 9 + 7

p = []
m = []
for i in a:
    if i > 0:p.append(i)
    elif i < 0:p.append(i)

p.sort(reverse=True)
m.sort()
double = []

for i in range(len(p) - 1):
    if i % 2 == 0:
        temp = p[i] * p[i + 1]
        double.append([temp, 1])
for i in range(len(m) - 1):
    if i % 2 == 0:
        temp = m[i] * m[i + 1]
        double.append([temp, 2])

double.sort(reverse=True)
res = 1
flag = 0
p = deque(p)
m = deque(m)
double = deque(double)
while k:
    if double and k - 2 >= 0:
        temp, ind = double.popleft()
        if ind == 1:
            p.popleft()
            p.popleft()
        else:
            m.popleft()
            m.popleft()
        res = (res * temp) % mod
        k -= 2
    else:
        if p:
            res = (res * p.popleft()) % mod
        else:
            res = (res * m.popleft()) % mod
        k -= 1
        
print(res)

### FIXED CODE ###

from collections import deque
n, k = map(int,input().split())
a = list(map(int,input().split()))
mod = 10 ** 9 + 7

p = []
m = []
for i in a:
    if i >= 0:p.append(i)
    elif i < 0:m.append(i)

p.sort(reverse=True)
m.sort()
res = 1
if n == k:
    for i in a:
        res = (res * i) %mod
    print(res)
    exit()
    
if len(p) == 0 and k % 2 == 1:
    for i in range(k):
        res = (res * m[-(i + 1)]) %mod
    print(res)

else:
    p_ind = 0
    m_ind = 0
    while k:
        if k == 1:
            res = (res * p[p_ind]) % mod
            break
        
        temp = p[p_ind] * p[p_ind + 1] if p_ind + 1 < len(p) else 0
        temp1 = m[m_ind] * m[m_ind + 1] if m_ind + 1 < len(m) else 0
        if temp > temp1:
            res = (res * p[p_ind]) %mod
            p_ind += 1
            k -= 1
        else:
            res = (res * temp1) %mod
            m_ind += 2
            k -= 2
    print(res)
n= int(input())
a=int(input())
b=int(input())
import math

c=(a*b)//math.gcd(a,b)
for i in range(n-2):
	b=int(input())
	c=(c*b)//math.gcd(c,b)

print(c)

### FIXED CODE ###

n= int(input())
a=int(input())

import math
if n==1:
	print(a)
	exit()

b=int(input())
c=(a*b)//math.gcd(a,b)
for i in range(n-2):
	b=int(input())
	c=(c*b)//math.gcd(c,b)

print(c)
import math
A, B, C = map(int, input().split())
if C%math.gcd(A, B) == 0:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

import fractions
A, B, C = map(int, input().split())
if C % fractions.gcd(A, B) == 0:
    print("YES")
else:
    print("NO")
L = int(input())
for i in range(20):
    if 2**i >  L :
        r = i-1
        break
#print(r)

res = []
for i in range(1, r+1):
    res.append([i, i+1, 0])
    res.append([i, i+1, 2**(i-1)])
print(res)

for t in range(r, 0, -1):
    if L >= 2**r + 2**(t-1):
        L -= 2**(t-1)
        res.append([t, r+1, L])

print(r+1, len(res))
for i in range(len(res)):
    print(res[i][0], res[i][1], res[i][2])


### FIXED CODE ###

import math
L = int(input())
r = int(math.log2(L))

res = []
for i in range(1, r+1):
    res.append([i, i+1, 0])
    res.append([i, i+1, 2**(i-1)])

for t in range(r, 0, -1):
    if L >= 2**r + 2**(t-1):
        L -= 2**(t-1)
        res.append([t, r+1, L])

print(r+1, len(res))
for i in range(len(res)):
    print(res[i][0], res[i][1], res[i][2])
import sys
sys.setrecursionlimit(1000000)

n, q = map(int, input().split())
v = [set() for _ in range(n+1)]
c = [0]*(n+1)

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

for _ in range(q):
  p, x = map(int, input().split())
  c[p] += x

def addcount(p, prev):
  v[p].remove(prev)
  for i in v[p]:
    c[i] += c[p]
    addcount(i, p)
  return None
addcount(1, 0)
  
print(' '.join(str(i) for i in c[1:]))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

def input():
  return sys.stdin.readline()[:-1]

n, q = map(int, input().split())
v = [[] for _ in range(n+1)]
c = [0]*(n+1)

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

for _ in range(q):
  p, x = map(int, input().split())
  c[p] += x

def addcount(p, prev):
  for i in v[p]:
    if i != prev:
      c[i] += c[p]
      addcount(i, p)
  return None
addcount(1, 0)
  
print(*c[1:])
keta = 0
count_sum = 0
for _ in range(M):
    d,c= map(int,input().split(' '))
    keta += c
    count_sum += d*c
additional = count_sum//10
if 9 < count_sum:
    print(keta-1 + (count_sum-1)//9)
else:
    print(keta-1)
'''

### FIXED CODE ###

M = int(input())
keta = 0
count_sum = 0
for _ in range(M):
    d,c= map(int,input().split(' '))
    keta += c
    count_sum += d*c
additional = count_sum//10
if 9 < count_sum:
    print(keta-1 + (count_sum-1)//9)
else:
    print(keta-1)
import fraction

N, X   = map(int, input().split())
x = list(map(int, input().split()))
assert len(x) == N

x.sort()

# distance between each two cities
dist = [x[i] - x[i-1] for i in range(1, len(x))]

# distance between the first city and the start point
dist.append(abs(x[0] - X))

def listgcd(xs):
    g = xs[0]
    for i in range(1, len(xs)):
        g = fraction.gcd(g, xs[i])
    return g

print(listgcd(dist))


### FIXED CODE ###

import fractions

N, X   = map(int, input().split())
x = list(map(int, input().split()))
assert len(x) == N

x.sort()

# distance between each two cities
dist = [x[i] - x[i-1] for i in range(1, len(x))]

# distance between the first city and the start point
dist.append(abs(x[0] - X))

def listgcd(xs):
    g = xs[0]
    for i in range(1, len(xs)):
        g = fractions.gcd(g, xs[i])
    return g

print(listgcd(dist))
books1= list(map(int, input().split()))
i=0
while(i<len(books)):
  if(books[i]==0):
    print(i+1)
    break
    i+=1

### FIXED CODE ###

books1= list(map(int, input().split()))
i=0
while(i<len(books1)):
  if(books1[i]==0):
    break
  i+=1
print(i+1)
# -*- coding: utf-8 -*-
import sys

class Tree:
    def __init__(self, v):
        self.v = 0
        self.counter = 0
        self.leaves = []
        self.offspring = []

[n, q] = [int(x) for x in sys.stdin.readline().rstrip().split()]

a = [0] * (n-1)
b = [0] * (n-1)
for i in range(n-1):
    [a[i], b[i]] = [int(x) for x in sys.stdin.readline().rstrip().split()]
p = [0] * q
x = [0] * q
for i in range(q):
    [p[i], x[i]] = [int(x) for x in sys.stdin.readline().rstrip().split()]

trees = [Tree(0)]
tree_dict = {}

for i in range(1,n+1):
    tree = Tree(i)
    trees.append(tree)
    tree_dict[i] = tree
    
root = tree_dict[1]
        
for i in range(n-1):
    tree_dict[a[i]].leaves.append(tree_dict[b[i]])

def rec_offspring(t: Tree):
    for c in t.leaves:
        rec_offspring(c)
    for c in t.leaves:
        t.offspring.extend(c.offspring)
    t.offspring.extend(t.leaves)

rec_offspring(trees[1])

for i in range(q):
    t = tree_dict[p[i]]
    t.counter += x[i]
    for c in t.offspring:
        c.counter += x[i]

print(' '.join(list(map(lambda x: str(x.counter), trees[1:]))))


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from collections import deque

n, q = map(int, input().split())

counts = [0] * (n+1)
adjs = {a: [] for a in range(1,n+1)}

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

costs = [[int(x) for x in input().split()] for i in range(q)]

for cost in costs:
    counts[cost[0]] += cost[1]

visited = set()
queue = deque()
queue.append(1)

while len(queue) > 0:
    a = queue.popleft()
    visited.add(a)
    for b in adjs[a]:
        if b in visited:
            continue
        counts[b] += counts[a]
        queue.append(b)

for c in counts[1:]:
    print(c, end=" ")
print()
x,n = map(int,input().split())
p = list(map(int,input().split()))
sa = []
num = []
for i in range(1,101):
    if i in p:
        continue
    sa.append(abs(x-i))
    num.append(i)

print(num[sa.index(min(sa))])


### FIXED CODE ###

x,n = map(int,input().split())
p = list(map(int,input().split()))
sa = []
num = []
for i in range(-110,110):
    if i in p:
        continue
    sa.append(abs(x-i))
    num.append(i)

print(num[sa.index(min(sa))])
str_len,input_str = map(str, str(input()).split('\n'))
half = int(int(str_len)/2)
if(str_len % 2 == 0 and input_str[0:half] == input_str[half:str_len]):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

str_len = int(input())
input_str = str(input())
half = int(int(str_len)/2)
if(str_len % 2 == 0 and input_str[0:half] == input_str[half:str_len]):
  print("Yes")
else:
  print("No")
# -*- coding: utf-8 -*-
n, d = map(int, input().split())
i = 0
num = 0
while i < n:
  x, y = map(int, input().split())
  _d = sqrt((x*x) + (y*y))
  if _d <= d:
    num += 1
  i += 1
 
print(num)

### FIXED CODE ###

import math
# -*- coding: utf-8 -*-
n, d = map(int, input().split())
i = 0
num = 0
while i < n:
  x, y = map(int, input().split())
  _d = math.sqrt((x*x) + (y*y))
  if _d <= d:
    num += 1
  i += 1
 
print(num)
S = int(input())
h =x // 3600;
m =x %3600 //60;
s =x % 60;
print(h, m, s, sep=':')

### FIXED CODE ###

x = int(input());
h = x // 3600;
m = x % 3600 // 60;
s = x % 60;
 
print(h,m,s,sep=':');
N=int(input())
if N=1:
  print('Hello World')
else:
  A=int(input())
  B=int(input())
  print(A+B)

### FIXED CODE ###

N=int(input())
if N==1:
  print('Hello World')
else:
  A=int(input())
  B=int(input())
  print(A+B)
N = int(input())
S = input()
ans = []
for i in range(1, N-1):
    a = set(S[:i])
    b = set(S[i:])
    ans.append(len(a.intersection(b)))
print(max(ans))


### FIXED CODE ###

N = int(input())
S = input()
if N == 2:
    print(len(set(S[0]).intersection(set(S[1]))))
else:
    ans = []
    for i in range(1, N-1):
        a = set(S[:i])
        b = set(S[i:])
        ans.append(len(a.intersection(b)))
    print(max(ans))
A = int(input())
B = int(input())
if A == B:
    print(2*A)
else:
    print(2*max(A,B)-1)

### FIXED CODE ###

n, m=[int(k) for k in input().split()]
cont=0
for i in range(2):
    if n>m: 
        cont+=n
        n-=1
    elif m>=n:
        cont+=m
        m-=1
print(cont)
import sys
from collections import deque
input = sys.stdin.readline

h, w = map(int, input().split())
maze = [list("#" * (w + 2))]
white = 0
for _ in [0] * h:
    line = "#" + input().strip() + "#"
    maze.append(list(line))
    white += line.count(".")

maze += [list("#" * (w + 2))]

q = deque()
q.append([1, 1])
maze[1][1] = 0
maze[-2][-2] = "goal"
#print(maze)

dir = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dis = 0
while q:
    x, y = q.pop()
    dis += 1

    for dx, dy in dir:
        next_x, next_y = x + dx, y + dy
        if maze[next_y][next_x] == ".":
            #print(next_y, next_x)
            q.append([next_y, next_x])
            maze[next_y][next_x] = dis
            
        if maze[next_y][next_x] == "goal":
            print(white - dis - 1)
            exit()
print(-1)


### FIXED CODE ###

import sys

h,w = map(int,input().split())

# マップを生成する。####で囲う。"."をカウントしておく(white)
m = []
m.append('#'*(w+2))
white = 0
for i in range(h):
  s = input()
  m.append(list('#' + s + '#'))
  white += s.count('.')
m.append('#'*(w+2))

stack = set([(1, 1)])
dist = 0

# stackがある限りループ
while len(stack) > 0:
  
  #ゴールまでの距離をカウントしていく
  dist += 1
  
  # 空のセットを用意
  next_w = set()
  
  for y, x in stack:
    m[y][x] = dist
    
    # ゴールに到着したら
    if (y, x) == (h, w):
      print(white - dist)
      exit()
      
 	# 上下左右に移動。
    for dx,dy in [0,1],[0,-1],[1,0],[-1,0]:
      # "."なら移動可能
      if m[y-dy][x-dx] == '.':
        next_w.add((y-dy,x-dx))
  stack = next_w

print('-1')
n = int(input)
if n % 2 == 0:
  print(1/2)
else:
  print((n/2 + 0.5)/n)


### FIXED CODE ###

n = int(input())
if n % 2 == 0:
  print(1/2)
else:
  print((n/2 + 0.5)/n)
n = int(input())
l = list(map(int, input().split()))
import numpy as np
ll = np.empty(int(n * (n - 1) / 2))

for i in range(N):
  for j in range(i + 1, N):
    ll[k] = l[i] * l[j]
    k += 1
print(np.sum(ll))

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
s = 0
for i in range(n):
  j = i + 1
  while j <= n - 1:
    s += l[i] * l[j]
    j += 1
print(s)
N,A,B=map(int,input().split())
ans=0
for i in range(N+1):
  if A<=sum(map(str,i))<=B:
    ans+=1
print(ans)    

### FIXED CODE ###

N,A,B=map(int,input().split())
ans=0
for i in range(N+1):
  if A<=sum(map(int,str(i)))<=B:
    ans+=i
print(ans)
import numpy as np

H, W, M = 5, 5, 10
ARR = [
    [2, 5],
    [4, 3],
    [2, 3],
    [5, 5],
    [2, 2],
    [5, 4],
    [5, 3],
    [5, 1],
    [3, 5],
    [1, 4]
]

H, W, M = map(int,input().split())
ARR = []
for i in range(M):
    ARR.append(list(map(int,input().split())))


# H, W, M = 2, 3, 3
# ARR = [
#     [2, 2],
#     [1, 1],
#     [1, 3]
# ]


def calculate(h, w, m, arr):
    srr = np.zeros((h,w))

    for ar in arr:
        h = ar[0] - 1
        w = ar[1] - 1
        srr[h][w] = 1

    res1 = np.sum(srr, axis=1)

    largestHIndex = np.argmax(res1)

    res2 = np.sum(srr, axis=0)
    trr = res2 - srr[largestHIndex]

    largestWIndex = np.argmax(trr)
    print(int(trr[largestWIndex] + res1[largestHIndex]))

calculate(H, W, M, ARR)


### FIXED CODE ###

H, W, M = map(int,input().split())
ARR = []

for i in range(M):
    ARR.append(list(map(int,input().split())))

def calculate(h, w, m, arr):
    points = set()



    rowSum = [0 for i in range(h)]
    columnSum = [0 for i in range(w)]

    for ar in arr:
        points.add((ar[0]-1, ar[1]-1))
        rowSum[ar[0]-1] += 1
        columnSum[ar[1]-1] += 1

    maxRowSum = max(rowSum)
    maxColumnSum = max(columnSum)


    a0 = []

    for i in range(len(rowSum)):
        if rowSum[i] == maxRowSum:
            a0.append(i)

    a1 = []
    for i in range(len(columnSum)):
        if columnSum[i] == maxColumnSum:
            a1.append(i)

    result = 0
    for hIndex in a0:
        for wIndex in a1:

            if (hIndex,wIndex) in points:
                result = max(result, maxRowSum + maxColumnSum - 1)
            else:
                result = max(result, maxRowSum + maxColumnSum)
                print(result)
                exit()

    print(result)


calculate(H, W, M, ARR)
s=list(input())
divide=["dream","erase","eraser","dreamer"]
def dfs(n):
        if n==len(s):
                return True
        for i in divide:
                if n+len(i)<=len(s):
                        if "".join(s[n:n+len(i)])==i:
                                if dfs(n+len(i)):
                                        return True
        return False
print("YES") if dfs(0) else print("NO")


### FIXED CODE ###

s=input().replace("eraser",",").replace("erase",",").replace("dreamer",",").replace("dream",",").replace(",","")
print("YES" if s=="" else "NO")
prices = list(map(int,input().split()))
prices.sort()
print(price[0]+price[1])

### FIXED CODE ###

prices = list(map(int,input().split()))
prices.sort()
print(prices[0]+prices[1])
import math
N = int(input())
sheet = []
for i in range(N):
  line = input().split()
  sheet += [(int(line[0]), int(line[1]))]

dic = {}
for i in range(N):
  start = sheet[i]
  for j in range(i+1, N):
    vec = [(sheet[j][0]-start[0]), (sheet[j][1]-start[1])]
    size = math.gcd(vec[0],vec[1])
    vec[0] = vec[0]//size
    vec[1] = vec[1]//size
    vec = tuple(vec)
    if vec not in dic.keys():
      dic[vec] = set([j])
    else:
      dic[vec].add(j)
m = 0
for s in dic.values():
  if len(s)>m:
    m = len(s)
print(N-m)

### FIXED CODE ###

N,*L = map(int, open(0).read().split())
ls = [0]*N
for i,c in enumerate(zip(*[iter(L)]*2)):
  ls[i] = c
ls.sort()
pls = []
for i in range(N):
  for j in range(i+1,N):
    a,b = ls[i]
    x,y = ls[j]
    pls += [(x-a,y-b)]
ans = 10**10
for X,Y in pls:
  s = set()
  m = 0
  for x,y in ls:
    if (x-X, y-Y) not in s:
      m += 1
    s.add((x,y))
  ans = min(m,ans)
if N==1:
  ans = 1
print(ans)
N,x =map(int, input().split())
candy = list(map(int, input().split()))
eat = 0

for i in range(N - 1):
    if(candy[i] + candy[i + 1] > x):
        ex = candy[i] + candy[i + 1] - x
        eat += ex
        if(candy[i + 1] >= ex):
            candy[i + 1] -= ex
        else:
            candy[i] -= ex - cndy[i + 1]
            candy[i + 1] = 0
print(eat)

### FIXED CODE ###

N,x =map(int, input().split())
candy = list(map(int, input().split()))
eat = 0

for i in range(N - 1):
    if(candy[i] + candy[i + 1] > x):
        ex = candy[i] + candy[i + 1] - x
        eat += ex
        if(candy[i + 1] >= ex):
            candy[i + 1] -= ex
        else:
            candy[i] -= ex - candy[i + 1]
            candy[i + 1] = 0
print(eat)
import math

n,m = map(int, input().split())
s = input()
t = input()

gcd = math.gcd(n,m)
lcm = n*m//gcd

a = lcm//n
b = lcm//m

flag=0
le = min(n,m)//(min(n,m)//gcd)

for i in range(le):
    # print(i*b, i*a)
    if s[i*b]!=t[i*a]:
        flag=1

if flag==1:
    print(-1)
else:
    print(lcm)

### FIXED CODE ###

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

n,m = map(int, input().split())
s = input()
t = input()

gcd_ = gcd(n,m)
lcm = n*m//gcd_

a = lcm//n
b = lcm//m

flag=0
le = min(n,m)//(min(n,m)//gcd_)

for i in range(le):
    if s[i*b]!=t[i*a]:
        flag=1

if flag==1:
    print(-1)
else:
    print(lcm)
n=int(input())
x = ""
while n!=0:
    x = str(n%2) + x
    n = -(n//2)
if x = "":
    print(0)
else:
    print(x)

### FIXED CODE ###

n=int(input())
x = ""
while n!=0:
    x = str(n%2) + x
    n = -(n//2)
if x == "":
    print(0)
else:
    print(x)
#from collections import Counter
#from itertools import combinations
n = int(input())
lst = ["".join(soted(list(input()))) for i in range(n)]
#lst2 = 1#Counter(lst)
#for i in len(lst):
#  print(i.values)


def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

#print(cmb(4,2),0,0,0)
cnt = 0
for i in Counter(lst).values():
  if i == 1:
    continue
  cnt += cmb(i, 2)
"""
for i in range(len(lst)-1):
  for j in range(i+1,len(lst)):
    #print(0)
    if lst[i]==lst[j]:
      cnt += 1
"""
print(cnt)

### FIXED CODE ###

from collections import Counter
#from itertools import combinations
n = int(input())
lst = ["".join(sorted(list(input()))) for i in range(n)]
#lst2 = 1#Counter(lst)
#for i in len(lst):
#  print(i.values)


def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

#print(cmb(4,2),0,0,0)
cnt = 0
for i in Counter(lst).values():
  if i == 1:
    continue
  cnt += cmb(i, 2)
"""
for i in range(len(lst)-1):
  for j in range(i+1,len(lst)):
    #print(0)
    if lst[i]==lst[j]:
      cnt += 1
"""
print(cnt)
for i in xrange(input()):
    a, b = map(int, raw_input().split())
    print a+b if len(str(a+b)) <= 80 else 'overflow'

### FIXED CODE ###

for i in xrange(input()):
    a = int(raw_input())
    b = int(raw_input())
    print a+b if len(str(a+b)) <= 80 else 'overflow'