Harryxun/stf_run huggingface dataset:
i = list(map(int,input().split()))
ans = ""
while len(ans) <= i[0]:
	blue = "b" * i[1]
	red = "r" * i[2]
	ans += blue
	ans += red
end = ans[:i[0]]
print(end.count("b"))

### FIXED CODE ###

n,a,b = map(int,input().split())
ans = n // (a + b)*a

rem = n % (a + b)

ans += min(rem,a)
print(ans)
import sys

args = sys.argv

if int(args[1]) == 0:
	result = 0
elif 13 > int(args[1]):
	result = int(args[2])/2
else:
	result = args[2]

print(result)

### FIXED CODE ###

import sys

a, b = map(int, input().split())

if 6 > a:
	b = 0
elif 13 > a:
	b = b/2

print(int(b))
from pattern.text.en import singularize

plurals = [int(input())]

singles = [singularize(plural) for plural in plurals]
print singles

### FIXED CODE ###

S=(input())
if S[-1]=='s':
    S = S + 'es'
else:
    S = S + 's'
print(S)
# -*- coding: utf-8 -*-
# 整数の入力
a = str(input())
# 文字列の入力

# 出力
print chr(ord(a) + 1)

### FIXED CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
a = str(input())
# 文字列の入力
 
# 出力
print(chr(ord(a) + 1))
from sys import setrecursionlimit

setrecursionlimit(10 ** 6)

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

graph   = [ [] for _ in range(N) ]
queries = { p: 0 for p in range(N) }

for _ in range(N - 1):
    a, b = map(lambda x: int(x) - 1, input().split())

    graph[a].append(b)
    graph[b].append(a)

for _ in range(Q):
    p, x = map(int, input().split())

    queries[p - 1] += x

answer = [ 0 ] * N

def dfs(p, p_before, acc):
    acc += queries[p]

    answer[p] = acc

    for child in graph[p]:
        if child == p_before:
            continue

        dfs(child, acc)

dfs(0, -1, 0)

print(*answer)

### FIXED CODE ###

from sys import setrecursionlimit

setrecursionlimit(10 ** 6)

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

graph   = [ [] for _ in range(N) ]
queries = { p: 0 for p in range(N) }

for _ in range(N - 1):
    a, b = map(lambda x: int(x) - 1, input().split())

    graph[a].append(b)
    graph[b].append(a)

for _ in range(Q):
    p, x = map(int, input().split())

    queries[p - 1] += x

answer = [ 0 ] * N

def dfs(p, p_before, acc):
    acc += queries[p]

    answer[p] = acc

    for child in graph[p]:
        if child == p_before:
            continue

        dfs(child, p, acc)

dfs(0, -1, 0)

print(*answer)
while 1:
    l,r=0,int(input())
    a=[int(input()) for _ in range(r)]
    r-=1;c=0
    k=int(input())
    while l<=r:
        c+=1
        m=(l+r)//2
        if a[m]==k:break
        if a[m]<k:l=m+1
        else:r=m-1
    print(c)

### FIXED CODE ###

while 1:
    l,r=0,int(input())
    if r==0:break
    a=[int(input()) for _ in range(r)]
    r-=1;c=0
    k=int(input())
    while l<=r:
        c+=1
        m=(l+r)//2
        if a[m]==k:break
        if a[m]<k:l=m+1
        else:r=m-1
    print(c)
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
a, b = map(int, input().split())
print(lcm(a, b))

### FIXED CODE ###

a, b = map(int, input().split())
ans = 0
if a > b:
  for i in range(1, a + 1):
    if b * i % a == 0:
      ans = b * i
      break
else:
  for i in range(1, b + 1):
    if a * i % b == 0:
      ans = a * i
      break
print(ans)
s = sorted(list(set(input()))) + ["A"] *26
t = "abcdefghijklmnopqrstuvwxyz"

ans = "None"
for i in range(len(s)):
	if s[i] != t[i]:
		ans = (t[i])
		break
print(ans) 

### FIXED CODE ###

s = sorted(list(set(input()))) + ["A"] *26
t = "abcdefghijklmnopqrstuvwxyz"

ans = "None"
for i in range(len(t)):
	if s[i] != t[i]:
		ans = (t[i])
		break
print(ans)
from collections import Counter
n = int(input())
coor = []
for i in range(n):
  x,y = map(int, input().split())
  coor.append([x,y])

dif = []
for i in range(n):
  for j in range(n):
    if i != j:
      dif.append((coor[i][0] - coor[j][0], coor[i][1] - coor[j][1]))
      
S = Counter(dif)
way = max(S.values())
print(n-way)

### FIXED CODE ###

from collections import Counter
n = int(input())
coor = []
for i in range(n):
  x,y = map(int, input().split())
  coor.append([x,y])
  
if n == 1:
  print(1)
  exit()

dif = []
for i in range(n):
  for j in range(n):
    if i != j:
      dif.append((coor[i][0] - coor[j][0], coor[i][1] - coor[j][1]))
      
S = Counter(dif)
way = max(S.values())
print(n-way)
import numpy as np
import sys
import itertools
read = sys.stdin.buffer.read
N = int(input())
XY = np.array(read().split(), np.int64).reshape(-1,2)

ans = 0
for ditour in itertools.permutations(range(N)):
	distance = 0
	for i in range(1,N):
		u = XY[ditour[i]] - XY[ditour[i-1]]
		distance += np.linalg.norm(u)

	ans += distance

for i in range(1,N+1):
	ans /= i

print(ans)

### FIXED CODE ###

import math

N = int(input())
x, y = [], []
for _ in range(N):
	xt, yt = map(int, input().split())
	x.append(xt)
	y.append(yt)

def bfs(flg, cp, tot):
	if flg.count(0) == 0:
		return tot

	ans = 0
	for np in [i for i in range(N) if flg[i] == 0]:
		d = ((x[cp]-x[np])**2 + (y[cp]-y[np])**2) ** (1/2)
		flg[np] = 1
		ans += bfs(flg, np, tot+d)
		flg[np] = 0

	return ans

flg = [0] * N

A = 0

for i in range(N):
	flg[i] = 1
	A += bfs(flg,i,0)
	flg[i] = 0

for i in range(1,N+1):
	A /= i

print(A)
B = int(input(N))
C = int(input(A))
D = B % 500
if D > C:
  print("no")
else:
  print("yes")

### FIXED CODE ###

N=int(input())
A=int(input())

if N % 500 <= A:
  print("Yes")
else:
  print("No")
# -*- coding: utf-8 -*-
import math

N = int(input())
As = list(map(int, input().split()))


def gcd_list(numbers):
    res = math.gcd(numbers[0], numbers[1])
    if len(numbers) > 2:
        for idx in range(2, len(numbers)):
            res = math.gcd(res, numbers[idx])
    return res


max_gcd = 0
if(N) == 2:
    max_gcd = max(As)
else:
    for i in range(N):
        others = [As[j] for j in range(N) if j != i]
        max_gcd = max(gcd_list(others), max_gcd)

print(max_gcd)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import fractions

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

L = [0] * (N + 2)
R = [0] * (N + 2)

for i in range(0, N):
    L[i + 1] = fractions.gcd(L[i], A[i + 1])

for i in range(N, 0, -1):
    R[i] = fractions.gcd(R[i + 1], A[i])

print(max(fractions.gcd(L[i], R[i + 2]) for i in range(0, N)))
from sys import exit

S = str(input())#["F","F","T","F"]
Gx, Gy = [int(n) for n in input().split()]#[4,4]
Xds = []
Yds = []
X = True
L = len(S)
for s in S.split("T"):
    if X:
        Xds.append(len(s))
    else:
        Yds.append(len(s))
    X = not X
# print(Xds)
# print(Yds)
memox = [[False for _ in range(2*L)] for __ in range(len(Xds))]
memoy = [[False for _ in range(2*L)] for __ in range(len(Yds))]

def move(current, i, Ds,memo):
    if i == len(Ds): return
    pm = current+Ds[i]
    memo[i][pm] = True
    move(pm, i+1,Ds,memo)
    nm = current-Ds[i]
    memo[i][nm] = True
    move(nm, i+1,Ds,memo)
memox[0][Xds[0]] = True
move(Xds[0],1, Xds,memox)
move(0,0, Yds,memoy)
# print(Xds)
# print(Yds)
# print(memox)
# print(memoy)
if not (memox != [] or memoy != []):
    print(memox[len(Xds)-1][Gx] and memoy[len(Yds)-1][Gy])
elif (memox == [] and memoy != []):
    print(0==Gx and memoy[len(Yds)-1][Gy])
else:
    print(memox[len(Xds)-1][Gx] and 0==Gy)


### FIXED CODE ###

from sys import exit
from collections import defaultdict
import itertools
# dic = defaultdict(int)
# N = int(input())
# a = [int(input()) for _ in range(N)]
S = str(input())
x,y = [int(n) for n in input().split()]

dx = []
dy = []
X = True
tmp = 0


S = [len(s) for s in S.split("T")]
dx = S[0::2]
dy = S[1::2]
x -= dx[0]
del dx[0]

def check(d, p):
    memo = set([0])
    for t in d:
        memo = {a+b for a,b in itertools.product(memo, [-t, t])}
    return (p in memo)


print("Yes" if check(dx,x) and check(dy,y) else "No")
from collections import deque
x,y,a,b,c = map(int,input().split())
P = deque(sorted(list(map(int,input().split())),reverse=True)[:x])
Q = deque(sorted(list(map(int,input().split())),reverse=True)[:y])
R = deque(sorted(list(map(int,input().split())),reverse=True))
p = P.pop()
q = Q.pop()
r = R.popleft()
ans = 0
while (p < r or q < r) and r != 0:
    ans += r
    if len(R) != 0:   
        r = R.pop()
    else:
        r = 0
    if p < q:
        if len(p) != 0:   
            p = P.pop()
        else:
            p = 10**10
    else:
        if len(Q) != 0:   
            q = Q.pop()
        else:
            q = 10**10
            
ans += sum(P)+sum(Q)
if p != 10**10:
    ans += p
if q != 10**10:
    ans += q
print(ans)

### FIXED CODE ###

from collections import deque
x,y,a,b,c = map(int,input().split())
P = deque(sorted(list(map(int,input().split())),reverse=True)[:x])
Q = deque(sorted(list(map(int,input().split())),reverse=True)[:y])
R = deque(sorted(list(map(int,input().split())),reverse=True))
p = P.pop()
q = Q.pop()
r = R.popleft()
ans = 0

while p < r or q < r:
    ans += r
    if len(R) != 0:   
        r = R.popleft()
    else:
        r = 0
    if p < q:
        if len(P) != 0:   
            p = P.pop()
        else:
            p = 10**10
    else:
        if len(Q) != 0:   
            q = Q.pop()
        else:
            q = 10**10
            
ans += sum(P)+sum(Q)
if p != 10**10:
    ans += p
if q != 10**10:
    ans += q
print(ans)
n = int(input())
nums = list(map(int,input().split()))
num = 10**18
count = 1
if 0 in nums:
	print(0)
else:
	for i in range(n):
		count *= nums[i]
		if count < num:
			print(-1)
            break
		else:
			print(count)

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
ans = 1
if 0 in a:
  print(0)
else:
  for i in range(N):
    ans *= a[i]
    if ans > 10 ** 18:
      print(-1)
      break
  else:
    print(ans)
n=int(input())
s=input()
p=list(s.split())
s1=0
s2=0
for i in range(0,n)
  s1=s1+int(p[i])
  s2=s2+(int(p[i])*int(p[i]))
k= ((s1**2)-s2)//2
k=k%1000000007
//abcdef
print(k)


### FIXED CODE ###

n=int(input())
s=input()
p=list(s.split())
s1=0
s2=0
for i in range(0,n):
  s1=s1+int(p[i])
  s2=s2+(int(p[i])*int(p[i]))
k= ((s1**2)-s2)//2
k=k%1000000007
print(k)
N,A,B=map(int,input().split())

import numpy as np
blue=np.array([1]*A)
red=np.array([-1]*B)
ball=np.array(list(np.concatenate([blue,red]))*int(N/(A+B)+1))
print(np.count_nonzero(ball[0:N]==1))

### FIXED CODE ###

N,A,B=map(int,input().split())

r=N//(A+B)*A
s=N%(A+B)

x=r+min(A,s)
print(x)
n, legs= map(int, input().split(" "))

x = (legs - 2*n)/2
y = (4*n - legs)/2

if X%1==0 and y%1==0 and x>0 and y>0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n, legs= map(int, input().split(" "))

x = (legs - 2*n)/2
y = (4*n - legs)/2

if x%1==0 and y%1==0 and (x>=0 and y>=0):
  print('Yes')
else:
  print('No')
N=input()
A=input()
print(['No','Yes'][N%500<=A])

### FIXED CODE ###

N=int(input())
A=int(input())
print(['No','Yes'][N%500<=A])
import math
N, H = list(map(int, input().split()))
a = []
b = []
for _ in range(N):
    ta, tb = list(map(int, input().split()))
    a.append(ta)
    b.append(tb)

b = list(filter(lambda x: x > max(a), b))
b.sort()
b.reverse()
slashNum = math.ceil( (H - sum(b)) / max(a) )

dmg = slashNum * max(a)
for i in range(N):
    dmg += b[i]
    if dmg >= H:
        print(slashNum + i + 1)
        exit()

### FIXED CODE ###

N, H = list(map(int, input().split()))
maxA = 0
n = 0
b = []
for _ in range(N):
    ta, tb = list(map(int, input().split()))
    maxA = max(maxA, ta)
    b.append(tb)

b = list(filter(lambda x: x > maxA, b))
b.sort()

while H > 0 and b:
    H -= b.pop()
    n += 1

print(n + max(H-1, -1) // maxA + 1 )
l,r=map(int,input().split())
min1=2018
if r-l>=2018:
  print(0)
  exit()
else:
  for i in range(l,r):
    for j in range(i+1,r+1):
      min=min(i*j%2019,min1)
print(min1)
      


### FIXED CODE ###

l,r=map(int,input().split())
min1=2018
if r-l>=2018:
  print(0)
  exit()
else:
  for i in range(l,r):
    for j in range(i+1,r+1):
      min1=min(i*j%2019,min1)
print(min1)
import numpy as np
n=int(input())
a=list(map(int,input().split()))
# dp[i][j]:i番目の数字の中からj個数字を取った時の最大。(i//2)-1<=j<=(i+1)//2
# 求めるのはdp[n][n//2]
dp=np.zeros((n+1,(n+1)//2+1),np.int64)
dp[1,1]=a[0]
for i in range(2,n+1): #i番目の数字はa[i-1]
      for j in range(max(0,i//2-1),(i+1)//2+1):
            dp[i,j]=max(dp[i-2,j-1]+a[i-1],dp[i-1,j])
print(dp[n,n//2])

### FIXED CODE ###

from collections import defaultdict

n=int(input())
a=list(map(int,input().split()))
#n=2*pow(10,5)
#a=range(1,pow(10,5)+1)
# dp[i][j]:i番目の数字の中からj個数字を取った時の最大。(i//2)-1<=j<=(i+1)//2
# 求めるのはdp[n][n//2]
dp=defaultdict(lambda:-pow(10,18))
dp[(1,1)]=a[0]
for i in range(2,n+1): #i番目の数字はa[i-1]
      for j in range(i//2-1,(i+1)//2+1):
            if j==1:
                  dp[(i,j)]=max(dp[(i-1,1)],a[i-1])
            elif j==0:
                  dp[(i,j)]=0
            else:
                  dp[(i,j)]=max(dp[(i-2,j-1)]+a[i-1],dp[(i-1,j)])
print(dp[(n,n//2)])
s = input().split().sort()
t = input().split().sort()
ns= len(s)
nt= len(t)
can = True
for i in range(min(ns,nt)):
    if(s[i] > t[i]):
       can = False
       break
if(can and ns < nt):
    print('Yes')
else:
    print('No')





### FIXED CODE ###

s = ''.join(sorted(input()))
t = ''.join(sorted(input(),reverse=True))
if(s<t):
    print('Yes')
else:
    print('No')
N=input()
S,T=input().split()
print(*[s+t for s,t in zip(S,T)],sep="")

### FIXED CODE ###

import fractions as f
A,B=map(int,input().split())
print(int((A*B)/f.gcd(A,B)))
n,a,b = map(int,input().split())
for i in range(n):
  if a^b == 1<<i:
    break
else:
  print("NO")
  exit()
st = min(a,b)
bt = (a^b).bit_length()-1
def change(x):
  x ^= st
  if ((x>>bt)&1) ^ ((x>>(n-1))&1):
    x ^= (1<<bt)+(1<<(n-1))
  return x
if n == 1:
  print("YES")
  print(a,b)
  exit()
ls = [0]
x = 0
cnt = 1
while x != 1<<(n-1):
  cntc = cnt
  divcnt = 0
  while cntc%2 == 0:
    cntc //= 2
    divcnt += 1
  x ^= 1<<divcnt
  ls.append(x)
  cnt += 1
print("YES")
ansls = [change(ls[i]) for i in range(2**n)]
print(2/0)
if a < b:
  print(*ansls)
else:
  print(*ansls[::-1])

### FIXED CODE ###

n,a,b = map(int,input().split())
if bin(a^b).count("1")%2 == 0:
  print("NO")
  exit()
st = min(a,b)
dif = a^b
t = 1<<(n-1)
chls = []
chcnt = n-1
for i in range(n)[::-1]:
  if dif&1<<i:
    chls.append((chcnt,i))
    chcnt -= 1
def change(x,p,q):
  if (x>>p)&1 ^ (x>>q)&1:
    x ^= (1<<p)+(1<<q)
  return x
def changeall(x):
  for l,r in chls[::-1]:
    x = change(x,l,r)
  x ^= st
  return x
if n == 1:
  print("YES")
  print(a,b)
  exit()
ls = []
x = 0
for i in range(1,2**n):
  cnt = 0
  while i%2 == 0:
    i //= 2
    cnt += 1
  ls.append(1<<cnt)
chcnt += 1
while chcnt < n-1:
  i = chcnt+1
  ls[-2**i] //= 2
  ls[-2**(i-1)] *= 2
  ls[-2**(i-1)-2**i] *= 2
  chcnt += 2
nls = [0]
for i in ls:
  nls.append(nls[-1]^i)
print("YES")
ansls = [changeall(nls[i]) for i in range(2**n)]
if a < b:
  print(*ansls)
else:
  print(*ansls[::-1])
if val1 % 2 == 0:
        print(int((val1 / 2) * (val1 / 2)))
    else:
        val1 = val1 + 1
        print(int(((val1 / 2) * (val1 / 2)) - (val1 / 2)))

### FIXED CODE ###

n = int(input())
if n&1==0:
    print((n//2)**2)
else:
    print((n//2)*(n//2+1))
import collections

input()
p = list(map(int, input().split()))
map1 = collections.defualtdict(lambda:0)
map2 = collections.defaultdict(lambda:0)

for i, v in enumerate(p):
  map1[i+v] += 1
  map2[i-v] += 1

ans = 0
for i in map1:
  if i in map2:
    ans += map2[i]
print(i)

### FIXED CODE ###

import collections
 
input()
p = list(map(int, input().split()))
map1 = collections.defaultdict(lambda:0)
map2 = collections.defaultdict(lambda:0)
 
for i, v in enumerate(p):
  map1[i+v] += 1
  map2[i-v] += 1

ans = 0
for i in map1:
  if i in map2:
    ans += map1[i] * map2[i]

print(ans)
from collections import defaultdict
import sys
input = sys.stdin.readline

class FenwickTree:
    def __init__(self, n):
        self.n = n
        self.dat = [0] * n
        
    def add(self, i, x):
        while i < self.n:
            self.dat[i] += x
            i += i & (-i)
    def sum(self, i):
        res = 0
        while i > 0:
            res += self.dat[i]
            i -= i & (-i)
        return res
    def rangesum(self, l, r):
        return self.sum(r) - self.sum(l-1)

N, Q = map(int, input().split())
C = [0] + list(map(int,input().split()))

ql, qid = defaultdict(list), defaultdict(list)

for i in range(Q):
    l, r = map(int, input().split())
    ql[r].append(l)
    qid[r].append(i)

A = [0] * (N+1)
ANS = [0] * (N+1)

FT = FenwickTree(N+1)

for i in range(1, N+1):
    if A[C[i]]:
        FT.add(A[C[i]], -1)
    FT.add(i, +1)
    A[C[i]] = i
    for j in range(len(ql[i])):
        ANS[qid[i][j]] = FT.rangesum(ql[i][j],i)

for ans in ANS[:Q]:
    print(ans)

### FIXED CODE ###

import numpy as np

def solve(inp):
    def bit_add(arr, n, i, x):
        while i <= n:
            arr[i] += x
            i += i & -i

    def bit_sum(arr, i):
        result = 0
        while i > 0:
            result += arr[i]
            i ^= i & -i
        return result

    N, Q = inp[:2]
    C = inp[2: 2+N]
    L, R = inp[2+N::2] - 1, inp[3+N::2] - 1

    just_left = {}
    segments = []
    for i in range(N):
        c = C[i]
        if c in just_left:
            segments.append((i, 0, just_left[c], 0))
        just_left[c] = i

    for i in range(Q):
        segments.append((R[i], 1, L[i], i))

    segments.sort()
    bit = np.zeros(N + 2, dtype=np.int64)
    ans = np.zeros(Q, dtype=np.int64)

    for r, tp, l, i in segments:
        if tp == 0:
            bit_add(bit, N + 2, l + 2, 1)
        else:
            base = r - l + 1
            ans[i] = base - (bit_sum(bit, r + 2) - bit_sum(bit, l + 1))

    return ans

def main():
    inp = np.fromstring(open(0).read(), dtype=np.int64, sep=' ')
    ans = solve(inp)
    print("\n".join(map(str,ans)))
    

def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', '(i8[:],)')(solve)
    cc.compile()

if __name__ == '__main__':
    import sys
    if sys.argv[-1] == 'ONLINE_JUDGE':
        cc_export()
        exit(0)
    from my_module import solve
    main()
def cal(A,B):
    return A*B
cal(A,B)

### FIXED CODE ###

A,B=input().strip().split()
A,B=[int(A),int(B)]    
if A>=1 and A<=100:
    if B>=1 and B<=100:
        print(A*B)
N = int(input())
A = list(map(int, input().split()))

def up(i,pre):
  if i == len(A) - 1:
    return abs(A[pre] - A[i])
  res1 = res2 = 0
  if i + 2 <=len(A) -1:
    res1 = up(i + 1,i)
    res2 = up(i + 2,i)
    return min(abs(A[pre] - A[i]) + res1, abs(A[pre] - A[i]) + res2)
  elif  i + 1 <=len(A) -1:
    res1 = up(i + 1,i)
    return abs(A[pre] - A[i]) + res1
  else: return 0
  
if N>2:
 print(min(up(1,0),up(2,0)))
else:
  print(up(1,0))
    


  

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
dp = [0 for _ in range(len(A))]
dp[0] = 0 
for i in range(1,N):
    if i - 2>=0:
        dp[i] = min(dp[i-1] + abs(A[i] - A[i-1]),dp[i-2] + abs(A[i] - A[i-2]))
    else:
        dp[i] =dp[i-1] + abs(A[i] - A[i-1])

print(dp[len(A)-1])
n = int(input())
sum = 0
for i in range(1:n+1):
  sum +=i
print(sum)

### FIXED CODE ###

n = int(input())
sum = 0
for i in range(1,n+1):
  sum +=i
print(sum)
import re;print(['NO','YES'][re.match('A?KIHA?BA?RA?$',input())])

### FIXED CODE ###

import re;print(['NO','YES'][re.match('A?KIHA?BA?RA?$',input())!=None])
n = int(input())
s = 0

for i in range(n):
    a = list(input().split())
print(a)
l = [0]
r = [0]
for m in range(n):
    l.append(a[m])
    r.append(a[m+1])

print(l)
print(r)
for p in range(1,n+1):
    s += int(r[p])-int(l[p])+1

print(s)

### FIXED CODE ###

n = int(input())
s = 0
a = [input().split() for i in range(n)]

l = [0]
r = [0]
for m in range(n):
    l.append(a[m][0])
    r.append(a[m][1])

for p in range(1,n+1):
    s += int(r[p])-int(l[p])+1

print(s)
a,b,c=map(int,input().split())
if a>2019:
  print('TBD')
elif a<2019:
  print('Heisei')
else:
  if b>4:
    print('TBD')
  elif b<=4:
    print('Heisei')
    

### FIXED CODE ###

a,b,c=list(map(int,input().split('/')))
if b>4:
  print('TBD')
else:
  print('Heisei')
#  GNU nano 2.2.6              ????????????: 2_c.py                                  

n=raw_input()
k=n.split(n)
k.sort()
#k=[3,2,1]
print k[0],
print k[1],
print k[2]

### FIXED CODE ###

K=map(int,raw_input().split())
K.sort()
for i in range(len(K)):
 print K[i],
N, M = map(int,input().split())
a, b = map(int,input().split())
for i in range(M-1):
  l = []
  c, d = map(int,input().split())
  l1 = list(range(c,d+1))
  for j in l1:
    if a <= j <= b:
      l.append(j)
  a = l[0]
  b = l[-1]
print(len(l))

### FIXED CODE ###

n, m = map(int,input().split())
a, b = map(int,input().split())
cnt = 0
for i in range(1, m):
  l, r = map(int,input().split())
  if (l > b and r > b) or (l < a and r < a):
    print(0)
    exit()
  if a<=l<=b:
    a = l
  if r <= b:
    b = r
print(b-a+1)
inf = input().split()
H = int(inf[0])
W = int(inf[1])
dic = {}
score = {}
m = 0

for h in range(H+2):
  if h==0 or h==H+1:
    for w in range(W+2):
      dic[(h,w)] = False
      score[(h,w)] = (0,0)
  else:
    line = input()
    dic[(h,0)] = False
    dic[(h,W+1)] = False
    score[(h,0)] = (0,0)
    score[(h, w+1)] = (0,0)
    for w in range(W):
      if line[w]=='.':
        dic[(h,w+1)] = True
      else:
        dic[(h,w+1)] = False
      
for h in range(1,H+1):
  for w in range(1,W+1):
    score[(h,w)]=(0,0)
    if dic[(h,w)]:
      s = 0
      hs = 0
      ws = 0
      if dic[(h-1,w)]:
        s += score[(h-1,w)][0]
        hs += score[(h-1,w)][0]
      else:
        i = h+1
        while dic[(i,w)]:
          score[(h,w)]+=1
          i+=1
      if dic[(h, w-1)]:
        s += score[(h, w-1)][1]
        ws += score[(h,w-1)][1]
      else:
        j = w+1
        while dic[(h,j)]:
          score[(h,w)]+=1
          j+=1
      if m < s:
        m = s
print(m)


### FIXED CODE ###

inf = input().split()
H = int(inf[0])
W = int(inf[1])
sheet = [[] for i in range(H+2)]
score = [[] for i in range(H+2)]
m = 0
 
for h in range(H+2):
  if h==0 or h==H+1:
    a = [False]*(W+2)
    b = [(0,0)]*(W+2)
    sheet[h]=a
    score[h]=b
  else:
    line = input()
    a = []
    b = []
    a += [False]
    b += [(0,0)]
    for w in range(W):
      b+=[(0,0)]
      if line[w]=='.':
        a += [True]
      else:
        a += [False]
    a += [False]
    b += [(0,0)]
    sheet[h]=a
    score[h]=b
      
for h in range(1,H+1):
  for w in range(1,W+1):
    if sheet[h][w]:
      s = 0
      hs = 0
      ws = 0
      if sheet[h-1][w]:
        hs += score[h-1][w][0]
      else:
        i = h+1
        while sheet[i][w]:
          hs+=1
          i+=1
      if sheet[h][w-1]:
        ws += score[h][w-1][1]
      else:
        j = w+1
        while sheet[h][j]:
          ws+=1
          j+=1
      s = 1 + hs + ws
      score[h][w]=(hs, ws)
      if m < s:
        m = s
print(m)
n = int(input())
a = [int(x) for x in input().split()]
q = int(input())
bc=[]
for i in range(q):
    bc.append([int(x) for x in input().split()])

a_cnt=[0]*(10**5)

for i in range(len(a)):
	a_cnt[a[i]]+=1

a_goukei=sum(a)

for gyou in range(q):
	a_goukei+=(bc[gyou][1]-bc[gyou][0])*a_cnt[bc[gyou][0]]
	print(a_goukei)
	a_cnt[bc[gyou][1]]+=a_cnt[bc[gyou][0]]
	a_cnt[bc[gyou][0]]=0

### FIXED CODE ###

n = int(input())
a = [int(x) for x in input().split()]
q = int(input())
bc=[]
for i in range(q):
    bc.append([int(x) for x in input().split()])

a_cnt=[0]*(10**5+1)

for i in range(len(a)):
	a_cnt[a[i]]+=1

a_goukei=sum(a)

for gyou in range(q):
	a_goukei+=(bc[gyou][1]-bc[gyou][0])*a_cnt[bc[gyou][0]]
	print(a_goukei)
	a_cnt[bc[gyou][1]]+=a_cnt[bc[gyou][0]]
	a_cnt[bc[gyou][0]]=0