Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

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

MOD = 10**9+7

dp = [0]*(N+1)

dp[0]=1

A = [int(eval(input())) for i in range(M)]

ban = [1]*(N+1)

for a in A:

    ban[a]=0

for i in range(N):

    if i-1>=0:

        dp[i+1]=dp[i]*ban[i]+dp[i-1]*ban[i-1]

    else:

        dp[i+1]=dp[i]*ban[i]

    dp[i+1] %= MOD

print((dp[N]))

# optimized version of the same code:

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

A = [int(eval(input())) for i in range(M)]

MOD = 10**9+7

A = set(A)

dp = [0]*(N+1)

dp[0] = 1

for i in range(1,N+1):

    if i in A:

        continue

    if i == 1:

        dp[1] = dp[0]

    else:

        dp[i] = (dp[i-1]+dp[i-2])%MOD

print((dp[N]))

N, M = list(map(int, input().split()))
MOD = 10**9 + 7
dp = [0] * (N + 1)
dp[0] = 1
A = [int(eval(input())) for i in range(M)]
ban = [1] * (N + 1)
for a in A:
    ban[a] = 0
for i in range(N):
    if i - 1 >= 0:
        dp[i + 1] = dp[i] * ban[i] + dp[i - 1] * ban[i - 1]
    else:
        dp[i + 1] = dp[i] * ban[i]
    dp[i + 1] %= MOD
print((dp[N]))

N, M = list(map(int, input().split()))
A = [int(eval(input())) for i in range(M)]
MOD = 10**9 + 7
A = set(A)
dp = [0] * (N + 1)
dp[0] = 1
for i in range(1, N + 1):
    if i in A:
        continue
    if i == 1:
        dp[1] = dp[0]
    else:
        dp[i] = (dp[i - 1] + dp[i - 2]) % MOD
print((dp[N]))

+A = [int(eval(input())) for i in range(M)]

-A = [int(eval(input())) for i in range(M)]


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

from math import sqrt, ceil, factorial

from collections import defaultdict

def prime_factors(n):

    i = 2

    factors = defaultdict(int)

    while i * i <= n:

        if n % i:

            i += 1

        else:

            n //= i

            factors[i] += 1

    if n > 1:

        factors[n] += 1

    return factors

N, M = [int(elem) for elem in input().split(' ')]

# 素因数分解

prime_numbers = prime_factors(M)

sum = 1

fac_N_m1 = factorial(N - 1)

for value in list(prime_numbers.values()):

    bunshi = 1

    saisho = value + N - 1

    for _ in range(value):

        bunshi *= saisho

        saisho -= 1

    sum *= (bunshi // factorial(value))

print((sum % (10**9 + 7)))

# optimized version of the same code:

from collections import defaultdict

def prime_factorize(num):

    prime_numbers = defaultdict(int)

    i = 2

    while i * i <= num:

        if num % i == 0:

            while num % i == 0:

                prime_numbers[i] += 1

                num //= i

        i += 1

    if num != 1:

        prime_numbers[num] += 1

    return prime_numbers

MOD = 10**9 + 7

N, M = [int(elem) for elem in input().split()]

prime_numbers = prime_factorize(M)

num_sequences = 1

for exponent in list(prime_numbers.values()):

    denomimator = 1

    numerator = 1

    for i in range(1, exponent + 1):

        denomimator *= (N + exponent - i)

        numerator *= i

    num_sequences *= denomimator // numerator

    num_sequences %= MOD

print(num_sequences)

from math import sqrt, ceil, factorial
from collections import defaultdict

def prime_factors(n):
    i = 2
    factors = defaultdict(int)
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors[i] += 1
    if n > 1:
        factors[n] += 1
    return factors

N, M = [int(elem) for elem in input().split(" ")]
# 素因数分解
prime_numbers = prime_factors(M)
sum = 1
fac_N_m1 = factorial(N - 1)
for value in list(prime_numbers.values()):
    bunshi = 1
    saisho = value + N - 1
    for _ in range(value):
        bunshi *= saisho
        saisho -= 1
    sum *= bunshi // factorial(value)
print((sum % (10**9 + 7)))

from collections import defaultdict

def prime_factorize(num):
    prime_numbers = defaultdict(int)
    i = 2
    while i * i <= num:
        if num % i == 0:
            while num % i == 0:
                prime_numbers[i] += 1
                num //= i
        i += 1
    if num != 1:
        prime_numbers[num] += 1
    return prime_numbers

MOD = 10**9 + 7
N, M = [int(elem) for elem in input().split()]
prime_numbers = prime_factorize(M)
num_sequences = 1
for exponent in list(prime_numbers.values()):
    denomimator = 1
    numerator = 1
    for i in range(1, exponent + 1):
        denomimator *= N + exponent - i
        numerator *= i
    num_sequences *= denomimator // numerator
    num_sequences %= MOD
print(num_sequences)

-N, M = [int(elem) for elem in input().split(" ")]

-for value in list(prime_numbers.values()):

+N, M = [int(elem) for elem in input().split()]

+for exponent in list(prime_numbers.values()):

+        denomimator *= N + exponent - i

+    num_sequences *= denomimator // numerator


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

def main():

    A, B, AB, X, Y = list(map(int, input().split()))

    M = max(X, Y)

    k = 0

    ans = A * X + B * Y

    while True:

        ans = min(

            ans,

            AB * k * 2 + max(0, X - k) * A + max(0, Y - k) * B

        )

        if k >= M: break

        k += 1

    print(ans)

if __name__ == '__main__':

    main()

# optimized version of the same code:

def main():

    A, B, C, X, Y = list(map(int, input().split()))

    ans = 1 << 30

    c = 0  # even

    while True:

        j = c // 2

        t = A * max(0, X - j) + B * max(0, Y - j) + C * c

        if ans <= t: break

        ans = t

        c += 2

    print(ans)

if __name__ == '__main__':

    main()

def main():
    A, B, AB, X, Y = list(map(int, input().split()))
    M = max(X, Y)
    k = 0
    ans = A * X + B * Y
    while True:
        ans = min(ans, AB * k * 2 + max(0, X - k) * A + max(0, Y - k) * B)
        if k >= M:
            break
        k += 1
    print(ans)

if __name__ == "__main__":
    main()

def main():
    A, B, C, X, Y = list(map(int, input().split()))
    ans = 1 << 30
    c = 0  # even
    while True:
        j = c // 2
        t = A * max(0, X - j) + B * max(0, Y - j) + C * c
        if ans <= t:
            break
        ans = t
        c += 2
    print(ans)

if __name__ == "__main__":
    main()

-    A, B, AB, X, Y = list(map(int, input().split()))

+    A, B, C, X, Y = list(map(int, input().split()))

-        ans = min(ans, AB * k * 2 + max(0, X - k) * A + max(0, Y - k) * B)


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import sys

init = ''.join(sys.stdin.read().split())

# Bidirectional search using breadth-first search

def solve(start, goal):

    if start == goal:

        return 0

    generated_state = {start: 0, goal: 1}   # 0: foreward, 1: backward

    step = {start: 0, goal: 0}

    s = 0

    c_d = [(start, 0), (goal, 1)] # configure and direction

    while True:

        q = iter(c_d)

        c_d = []

        s += 1

        for c, d in q:

            i = c.find('0')

            if 0 <= i <= 5:

                t = str.maketrans('0' + c[i+3], c[i+3] + '0')

                t_c = c.translate(t)

                if t_c in generated_state:

                    if generated_state[t_c] != d:

                        return s + step[t_c]

                else:

                    generated_state[t_c] = d

                    step[t_c] = s

                    c_d.append((t_c, d))

            if i >= 3:

                t = str.maketrans('0' + c[i-3], c[i-3] + '0')

                t_c = c.translate(t)

                if t_c in generated_state:

                    if generated_state[t_c] != d:

                        return s + step[t_c]

                else:

                    generated_state[t_c] = d

                    step[t_c] = s

                    c_d.append((t_c, d))

            if i == 0 or i == 1 or i == 3 or i == 4 or i == 6 or i == 7:

                t = str.maketrans('0' + c[i+1], c[i+1] + '0')

                t_c = c.translate(t)

                if t_c in generated_state:

                    if generated_state[t_c] != d:

                        return s + step[t_c]

                else:

                    generated_state[t_c] = d

                    step[t_c] = s

                    c_d.append((t_c, d))

            if i == 1 or i == 2 or i == 4 or i == 5 or i == 7 or i == 8:

                t = str.maketrans('0' + c[i-1], c[i-1] + '0')

                t_c = c.translate(t)

                if t_c in generated_state:

                    if generated_state[t_c] != d:

                        return s + step[t_c]

                else:

                    generated_state[t_c] = d

                    step[t_c] = s

                    c_d.append((t_c, d))

print((solve(init, '123456780')))

# optimized version of the same code:

adjacent = (

    (1, 3),       # 0

    (0, 2, 4),    # 1

    (1, 5),       # 2

    (0, 4, 6),    # 3

    (1, 3, 5, 7), # 4

    (2, 4, 8),    # 5

    (3, 7),       # 6

    (4, 6, 8),    # 7

    (5, 7)        # 8

)

import collections

GOAL = [1, 2, 3, 4, 5, 6, 7, 8, 0]

# Bidirectional search using breadth-first search

def solve(start):

    if start == GOAL:

        return 0

    # 0: forward, 1: backward

    generated_state = {tuple(start): 0, tuple(GOAL): 1}

    step = {tuple(start): 0, tuple(GOAL): 0}

    s = 0

    state1 = [(start, 0), (GOAL, 1)]

    while state1:

        state2 = state1[:]

        state1 = []

        s += 1

        for s2, d in state2:

            i = s2.index(0)

            for p in adjacent[i]:

                s1 = s2[:]

                s1[i], s1[p] = s1[p], 0

                key = tuple(s1)

                if key in generated_state:

                    if generated_state[key] != d:

                        return s + step[key]

                    continue

                state1.append((s1, d))

                generated_state[key] = d

                step[key] = s

import sys

start = list(map(int, sys.stdin.read().split()))

print((solve(start)))

import sys

init = "".join(sys.stdin.read().split())
# Bidirectional search using breadth-first search
def solve(start, goal):
    if start == goal:
        return 0
    generated_state = {start: 0, goal: 1}  # 0: foreward, 1: backward
    step = {start: 0, goal: 0}
    s = 0
    c_d = [(start, 0), (goal, 1)]  # configure and direction
    while True:
        q = iter(c_d)
        c_d = []
        s += 1
        for c, d in q:
            i = c.find("0")
            if 0 <= i <= 5:
                t = str.maketrans("0" + c[i + 3], c[i + 3] + "0")
                t_c = c.translate(t)
                if t_c in generated_state:
                    if generated_state[t_c] != d:
                        return s + step[t_c]
                else:
                    generated_state[t_c] = d
                    step[t_c] = s
                    c_d.append((t_c, d))
            if i >= 3:
                t = str.maketrans("0" + c[i - 3], c[i - 3] + "0")
                t_c = c.translate(t)
                if t_c in generated_state:
                    if generated_state[t_c] != d:
                        return s + step[t_c]
                else:
                    generated_state[t_c] = d
                    step[t_c] = s
                    c_d.append((t_c, d))
            if i == 0 or i == 1 or i == 3 or i == 4 or i == 6 or i == 7:
                t = str.maketrans("0" + c[i + 1], c[i + 1] + "0")
                t_c = c.translate(t)
                if t_c in generated_state:
                    if generated_state[t_c] != d:
                        return s + step[t_c]
                else:
                    generated_state[t_c] = d
                    step[t_c] = s
                    c_d.append((t_c, d))
            if i == 1 or i == 2 or i == 4 or i == 5 or i == 7 or i == 8:
                t = str.maketrans("0" + c[i - 1], c[i - 1] + "0")
                t_c = c.translate(t)
                if t_c in generated_state:
                    if generated_state[t_c] != d:
                        return s + step[t_c]
                else:
                    generated_state[t_c] = d
                    step[t_c] = s
                    c_d.append((t_c, d))

print((solve(init, "123456780")))

adjacent = (
    (1, 3),  # 0
    (0, 2, 4),  # 1
    (1, 5),  # 2
    (0, 4, 6),  # 3
    (1, 3, 5, 7),  # 4
    (2, 4, 8),  # 5
    (3, 7),  # 6
    (4, 6, 8),  # 7
    (5, 7),  # 8
)
import collections

GOAL = [1, 2, 3, 4, 5, 6, 7, 8, 0]
# Bidirectional search using breadth-first search
def solve(start):
    if start == GOAL:
        return 0
    # 0: forward, 1: backward
    generated_state = {tuple(start): 0, tuple(GOAL): 1}
    step = {tuple(start): 0, tuple(GOAL): 0}
    s = 0
    state1 = [(start, 0), (GOAL, 1)]
    while state1:
        state2 = state1[:]
        state1 = []
        s += 1
        for s2, d in state2:
            i = s2.index(0)
            for p in adjacent[i]:
                s1 = s2[:]
                s1[i], s1[p] = s1[p], 0
                key = tuple(s1)
                if key in generated_state:
                    if generated_state[key] != d:
                        return s + step[key]
                    continue
                state1.append((s1, d))
                generated_state[key] = d
                step[key] = s

import sys

start = list(map(int, sys.stdin.read().split()))
print((solve(start)))

+# Bidirectional search using breadth-first search

+    generated_state = {tuple(start): 0, tuple(GOAL): 1}

+    step = {tuple(start): 0, tuple(GOAL): 0}

+                if key in generated_state:

+                    if generated_state[key] != d:

+                        return s + step[key]

+                generated_state[key] = d

-# Bidirectional search using breadth-first search

-    generated_state = {start: 0, goal: 1}  # 0: foreward, 1: backward

-    c_d = [(start, 0), (goal, 1)]  # configure and direction

-                if t_c in generated_state:

-                    if generated_state[t_c] != d:

-                        return s + step[t_c]

-                    generated_state[t_c] = d

-                    c_d.append((t_c, d))

-                if t_c in generated_state:

-                    if generated_state[t_c] != d:

-                        return s + step[t_c]

-                    generated_state[t_c] = d

-                    c_d.append((t_c, d))

-                if t_c in generated_state:

-                    if generated_state[t_c] != d:

-                        return s + step[t_c]

-                    generated_state[t_c] = d

-                    c_d.append((t_c, d))

-                if t_c in generated_state:

-                    if generated_state[t_c] != d:

-                        return s + step[t_c]

-                    generated_state[t_c] = d

-                    c_d.append((t_c, d))

+start = list(map(int, sys.stdin.read().split()))


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import numpy as np

n=int(eval(input()))

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

a_list_2=sorted(a_list,reverse=True)

a=np.array(a_list_2,dtype='uint8')

alice=0

bob=0

for i in range(n):

	if i%2==0:

		alice+=a[i]

	else:

		bob+=a[i]

print((alice-bob))

# optimized version of the same code:

n=int(eval(input()))

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

a.sort(reverse=True)

alice=0

bob=0

for i in range(n):

    if i%2==0:

        alice+=a[i]

    else:

        bob+=a[i]

print((alice-bob))

import numpy as np

n = int(eval(input()))
a_list = list(map(int, input().split()))
a_list_2 = sorted(a_list, reverse=True)
a = np.array(a_list_2, dtype="uint8")
alice = 0
bob = 0
for i in range(n):
    if i % 2 == 0:
        alice += a[i]
    else:
        bob += a[i]
print((alice - bob))

n = int(eval(input()))
a = list(map(int, input().split()))
a.sort(reverse=True)
alice = 0
bob = 0
for i in range(n):
    if i % 2 == 0:
        alice += a[i]
    else:
        bob += a[i]
print((alice - bob))

-a_list = list(map(int, input().split()))

-a_list_2 = sorted(a_list, reverse=True)


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

def popcount(x):

  r, q = 0, x

  while x:

    r += 1

    x &= x - 1

  return r, q

n = int(eval(input()))

r = list(range(n))

a = [[0, 0] for _ in r]

for i in r:

  for _ in range(int(eval(input()))):

    x, y = list(map(int, input().split()))

    a[i][y] |= 1 << (x - 1)

l = (1 << n) - 1

b = sorted(map(popcount, list(range(1, l + 1))))

ans = next((i for i, x in reversed(b)

           if all(a[j][0] & x == a[j][1] & l - x == 0 for j in r if x >> j & 1)), 0)

print(ans)

# optimized version of the same code:

from itertools import combinations, count

n = int(eval(input()))

r = list(range(n))

a = [(set(), set()) for _ in r]

for i in r:

  for _ in range(int(eval(input()))):

    x, y = list(map(int, input().split()))

    a[i][y].add(x - 1)

r = next(i for i in count(n, - 1) for x in map(set, combinations(r, i))

         if all(a[j][0].isdisjoint(x) and a[j][1] < x for j in x))

print(r)

def popcount(x):
    r, q = 0, x
    while x:
        r += 1
        x &= x - 1
    return r, q

n = int(eval(input()))
r = list(range(n))
a = [[0, 0] for _ in r]
for i in r:
    for _ in range(int(eval(input()))):
        x, y = list(map(int, input().split()))
        a[i][y] |= 1 << (x - 1)
l = (1 << n) - 1
b = sorted(map(popcount, list(range(1, l + 1))))
ans = next(
    (
        i
        for i, x in reversed(b)
        if all(a[j][0] & x == a[j][1] & l - x == 0 for j in r if x >> j & 1)
    ),
    0,
)
print(ans)

from itertools import combinations, count

n = int(eval(input()))
r = list(range(n))
a = [(set(), set()) for _ in r]
for i in r:
    for _ in range(int(eval(input()))):
        x, y = list(map(int, input().split()))
        a[i][y].add(x - 1)
r = next(
    i
    for i in count(n, -1)
    for x in map(set, combinations(r, i))
    if all(a[j][0].isdisjoint(x) and a[j][1] < x for j in x)
)
print(r)

+from itertools import combinations, count

-b = sorted(map(popcount, list(range(1, l + 1))))

+    for x in map(set, combinations(r, i))

+    if all(a[j][0].isdisjoint(x) and a[j][1] < x for j in x)


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

S = int(eval(input()))

MOD = 10 ** 9 + 7

#dp[i]最後に切った場所がi　スタートが1なのは、そこまでの切り方が1通りなので

#３以下はダメなので、3個前の結果を見るようにする

dp =  [0] * (S+1)

dp[0] = 1

for i in range(1, S+1):

    #たとえばi=6のとき、i=6で初めて切れ目を入れる時で＋１、i=3に切れ目をいれるときで＋１で合計＋２

    for j in range(0, (i-3)+1):

        dp[i] += dp[j]

        dp[i] %= MOD

print((dp[S]))

# optimized version of the same code:

S = int(eval(input()))

MOD = 10 ** 9 + 7

#dp[i]最後に切った場所がi　スタートが1なのは、そこまでの切り方が1通りなので

#３以下はダメなので、3個前の結果を見るようにする

dp =  [0] * (S+1)

dp[0] = 1

#これまでの和をxに保存しておく

x = 0

for i in range(1, S+1):

    if i-3 >= 0:

        x += dp[i-3]

        x %= MOD

    dp[i] = x

print((dp[S]))

S = int(eval(input()))
MOD = 10**9 + 7
# dp[i]最後に切った場所がi　スタートが1なのは、そこまでの切り方が1通りなので
# ３以下はダメなので、3個前の結果を見るようにする
dp = [0] * (S + 1)
dp[0] = 1
for i in range(1, S + 1):
    # たとえばi=6のとき、i=6で初めて切れ目を入れる時で＋１、i=3に切れ目をいれるときで＋１で合計＋２
    for j in range(0, (i - 3) + 1):
        dp[i] += dp[j]
        dp[i] %= MOD
print((dp[S]))

S = int(eval(input()))
MOD = 10**9 + 7
# dp[i]最後に切った場所がi　スタートが1なのは、そこまでの切り方が1通りなので
# ３以下はダメなので、3個前の結果を見るようにする
dp = [0] * (S + 1)
dp[0] = 1
# これまでの和をxに保存しておく
x = 0
for i in range(1, S + 1):
    if i - 3 >= 0:
        x += dp[i - 3]
        x %= MOD
    dp[i] = x
print((dp[S]))

+# これまでの和をxに保存しておく

-    # たとえばi=6のとき、i=6で初めて切れ目を入れる時で＋１、i=3に切れ目をいれるときで＋１で合計＋２


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

# bellman_ford : O(V E)

# dijkstra : O(E log V), 負辺は無理

# warshall_floyd : O(V**3)

import sys

sys.setrecursionlimit(10 ** 7)

input = sys.stdin.readline

def solve():

    inf = 10 ** 14 + 10

    def dfs(v: 'vertex_index, 0-indexed') -> None:

        for c, t in e[v]:

            if d[t] != inf:

                continue

            d[t] = d[v] + c

            dfs(t)

    n = int(eval(input()))

    e = tuple(set() for _ in range(n))

    for _ in range(n - 1):

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

        a -= 1

        b -= 1

        e[a].add((c, b))

        e[b].add((c, a))

    q, v = list(map(int, input().split()))

    v -= 1

    d = [inf] * n

    d[v] = 0

    dfs(v)

    for _ in range(q):

        x, y = list(map(int, input().split()))

        x -= 1

        y -= 1

        print((d[x] + d[y]))

if __name__ == '__main__':

    solve()

# optimized version of the same code:

# bellman_ford : O(V E)

# dijkstra : O(E log V), 負辺は無理

# warshall_floyd : O(V**3)

# deque

from collections import deque

import sys

input = sys.stdin.readline

def solve():

    inf = 10 ** 14 + 10

    n = int(eval(input()))

    e = tuple(set() for _ in range(n))

    for _ in range(n - 1):

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

        a -= 1

        b -= 1

        e[a].add((c, b))

        e[b].add((c, a))

    q, v = list(map(int, input().split()))

    v -= 1

    d = [inf] * n

    d[v] = 0

    dq = deque()

    for cost, to in e[v]:

        dq.append((cost, to, v))

        # (cost, to, parent)

    while dq:

        c, v, p = dq.popleft()

        if d[v] != inf:

            continue

        d[v] = d[p] + c

        for cost, to in e[v]:

            if to == p:

                continue

            dq.append((cost, to, v))

    for _ in range(q):

        x, y = list(map(int, input().split()))

        x -= 1

        y -= 1

        print((d[x] + d[y]))

if __name__ == '__main__':

    solve()

# bellman_ford : O(V E)
# dijkstra : O(E log V), 負辺は無理
# warshall_floyd : O(V**3)
import sys

sys.setrecursionlimit(10**7)
input = sys.stdin.readline

def solve():
    inf = 10**14 + 10

    def dfs(v: "vertex_index, 0-indexed") -> None:
        for c, t in e[v]:
            if d[t] != inf:
                continue
            d[t] = d[v] + c
            dfs(t)

    n = int(eval(input()))
    e = tuple(set() for _ in range(n))
    for _ in range(n - 1):
        a, b, c = list(map(int, input().split()))
        a -= 1
        b -= 1
        e[a].add((c, b))
        e[b].add((c, a))
    q, v = list(map(int, input().split()))
    v -= 1
    d = [inf] * n
    d[v] = 0
    dfs(v)
    for _ in range(q):
        x, y = list(map(int, input().split()))
        x -= 1
        y -= 1
        print((d[x] + d[y]))

if __name__ == "__main__":
    solve()

# bellman_ford : O(V E)
# dijkstra : O(E log V), 負辺は無理
# warshall_floyd : O(V**3)
# deque
from collections import deque
import sys

input = sys.stdin.readline

def solve():
    inf = 10**14 + 10
    n = int(eval(input()))
    e = tuple(set() for _ in range(n))
    for _ in range(n - 1):
        a, b, c = list(map(int, input().split()))
        a -= 1
        b -= 1
        e[a].add((c, b))
        e[b].add((c, a))
    q, v = list(map(int, input().split()))
    v -= 1
    d = [inf] * n
    d[v] = 0
    dq = deque()
    for cost, to in e[v]:
        dq.append((cost, to, v))
        # (cost, to, parent)
    while dq:
        c, v, p = dq.popleft()
        if d[v] != inf:
            continue
        d[v] = d[p] + c
        for cost, to in e[v]:
            if to == p:
                continue
            dq.append((cost, to, v))
    for _ in range(q):
        x, y = list(map(int, input().split()))
        x -= 1
        y -= 1
        print((d[x] + d[y]))

if __name__ == "__main__":
    solve()

-    def dfs(v: "vertex_index, 0-indexed") -> None:


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import queue

n = int(eval(input()))

abc = [[] for i in range(n+1)]

for i in range(n-1):

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

    abc[a].append([b,c])

    abc[b].append([a,c])

Q,k = list(map(int,input().split()))

xy = [[int(i) for i in input().split()] for j in range(Q)]

q = queue.Queue()

q.put(k)

path = [-1]*(n+1)

path[k] = 0

while not q.empty():

    tmp = q.get()

    for i in range(len(abc[tmp])):

        #print(abc[tmp])

        #exit()

        num = abc[tmp][i][0]

        if path[num] != -1:

            continue

        else:

            path[num] = path[tmp] + abc[tmp][i][1]

            q.put(num)

for i in range(Q):

    print((path[xy[i][0]]+path[xy[i][1]]))

# optimized version of the same code:

import queue

import sys

sys.setrecursionlimit(10**7)

n = int(eval(input()))

abc = [[] for i in range(n+1)]

for i in range(n-1):

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

    abc[a].append([b,c])

    abc[b].append([a,c])

Q,k = list(map(int,input().split()))

xy = [[int(i) for i in input().split()] for j in range(Q)]

q = queue.Queue()

q.put(k)

path = [-1]*(n+1)

path[k] = 0

def dfs(p):

    for i in range(len(abc[p])):

        num = abc[p][i][0]

        if path[num] != -1:

            continue

        else:

            path[num] = path[p] + abc[p][i][1]

            dfs(num)

dfs(k)

for i in range(Q):

    print((path[xy[i][0]]+path[xy[i][1]]))

import queue

n = int(eval(input()))
abc = [[] for i in range(n + 1)]
for i in range(n - 1):
    a, b, c = list(map(int, input().split()))
    abc[a].append([b, c])
    abc[b].append([a, c])
Q, k = list(map(int, input().split()))
xy = [[int(i) for i in input().split()] for j in range(Q)]
q = queue.Queue()
q.put(k)
path = [-1] * (n + 1)
path[k] = 0
while not q.empty():
    tmp = q.get()
    for i in range(len(abc[tmp])):
        # print(abc[tmp])
        # exit()
        num = abc[tmp][i][0]
        if path[num] != -1:
            continue
        else:
            path[num] = path[tmp] + abc[tmp][i][1]
            q.put(num)
for i in range(Q):
    print((path[xy[i][0]] + path[xy[i][1]]))

import queue
import sys

sys.setrecursionlimit(10**7)
n = int(eval(input()))
abc = [[] for i in range(n + 1)]
for i in range(n - 1):
    a, b, c = list(map(int, input().split()))
    abc[a].append([b, c])
    abc[b].append([a, c])
Q, k = list(map(int, input().split()))
xy = [[int(i) for i in input().split()] for j in range(Q)]
q = queue.Queue()
q.put(k)
path = [-1] * (n + 1)
path[k] = 0

def dfs(p):
    for i in range(len(abc[p])):
        num = abc[p][i][0]
        if path[num] != -1:
            continue
        else:
            path[num] = path[p] + abc[p][i][1]
            dfs(num)

dfs(k)
for i in range(Q):
    print((path[xy[i][0]] + path[xy[i][1]]))

-            path[num] = path[tmp] + abc[tmp][i][1]

+            path[num] = path[p] + abc[p][i][1]


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

#ABC 130 B

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

L= [int(j) for j in input().split()]

cnt=0

import numpy as np

jump = list(np.cumsum(L))

for j in jump:

    if j <= X:

        cnt+=1

    else:

        break

print((cnt+1))

# optimized version of the same code:

#ABC 130 B

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

L= [int(j) for j in input().split()]

cnt=0

d = 0

for l in L :

    d+=l

    if d <= X:

        cnt+=1

    else:

        break

print((cnt+1))

# ABC 130 B
N, X = list(map(int, input().split()))
L = [int(j) for j in input().split()]
cnt = 0
import numpy as np

jump = list(np.cumsum(L))
for j in jump:
    if j <= X:
        cnt += 1
    else:
        break
print((cnt + 1))

# ABC 130 B
N, X = list(map(int, input().split()))
L = [int(j) for j in input().split()]
cnt = 0
d = 0
for l in L:
    d += l
    if d <= X:
        cnt += 1
    else:
        break
print((cnt + 1))

-import numpy as np
-jump = list(np.cumsum(L))
-for j in jump:
-    if j <= X:
+d = 0
+for l in L:
+    d += l
+    if d <= X:


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import numpy as np

N = int(eval(input()))

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

list1 = [x-(i+1) for i,x in enumerate(list_ai)]

a1 = np.array(list1)

median1 = int(np.floor(np.median(a1)))

ans = np.sum(np.abs(a1-median1))

print(ans)

# optimized version of the same code:

import numpy as np

N = int(eval(input()))

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

a1 = np.array(list_ai)-np.arange(1,N+1)

median1 = int(np.floor(np.median(a1)))

ans = np.sum(np.abs(a1-median1))

print(ans)

import numpy as np

N = int(eval(input()))
list_ai = list(map(int, input().split()))
list1 = [x - (i + 1) for i, x in enumerate(list_ai)]
a1 = np.array(list1)
median1 = int(np.floor(np.median(a1)))
ans = np.sum(np.abs(a1 - median1))
print(ans)

import numpy as np

N = int(eval(input()))
list_ai = list(map(int, input().split()))
a1 = np.array(list_ai) - np.arange(1, N + 1)
median1 = int(np.floor(np.median(a1)))
ans = np.sum(np.abs(a1 - median1))
print(ans)

-list1 = [x - (i + 1) for i, x in enumerate(list_ai)]

+a1 = np.array(list_ai) - np.arange(1, N + 1)


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

def solve(string):

    x = int(string)

    a = {i**5: i for i in range(-10000, 10000)}

    for i in range(-10000, 10000):

        if x + i ** 5 in a:

            return str(f"{a[x+i**5]} {i}")

if __name__ == '__main__':

    import sys

    print((solve(sys.stdin.read().strip())))

# optimized version of the same code:

def solve(string):

    x = int(string)

    a = {i**5: i for i in range(-120, 121)}

    for i in range(-121, 121):

        if x + i ** 5 in a:

            return str(f"{a[x+i**5]} {i}")

if __name__ == '__main__':

    import sys

    print((solve(sys.stdin.read().strip())))

def solve(string):
    x = int(string)
    a = {i**5: i for i in range(-10000, 10000)}
    for i in range(-10000, 10000):
        if x + i**5 in a:
            return str(f"{a[x+i**5]} {i}")

if __name__ == "__main__":
    import sys

    print((solve(sys.stdin.read().strip())))

def solve(string):
    x = int(string)
    a = {i**5: i for i in range(-120, 121)}
    for i in range(-121, 121):
        if x + i**5 in a:
            return str(f"{a[x+i**5]} {i}")

if __name__ == "__main__":
    import sys

    print((solve(sys.stdin.read().strip())))


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

W,H,x,y,r = [int(i) for i in input().split()]

if x - r >= 0 and x + r <= W and y - r >= 0 and y + r <= H:

    print("Yes")

else:

    print("No")

# optimized version of the same code:

W, H, x, y, r = list(map(int, input().split()))

if r <= x <= W-r and r <= y <= H-r:

    print('Yes')

else:

    print('No')

W, H, x, y, r = [int(i) for i in input().split()]
if x - r >= 0 and x + r <= W and y - r >= 0 and y + r <= H:
    print("Yes")
else:
    print("No")

W, H, x, y, r = list(map(int, input().split()))
if r <= x <= W - r and r <= y <= H - r:
    print("Yes")
else:
    print("No")

-W, H, x, y, r = [int(i) for i in input().split()]

-if x - r >= 0 and x + r <= W and y - r >= 0 and y + r <= H:

+W, H, x, y, r = list(map(int, input().split()))

+if r <= x <= W - r and r <= y <= H - r:


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

# 解説を参考に作成

def solve():

    X = int(eval(input()))

    A, B = 0, 0

    for a in range(-200, 200):

        for b in range(-200, 200):

            if a ** 5 - b ** 5 == X:

                A, B = a, b

                break

    print((A, B))

if __name__ == '__main__':

    solve()

# optimized version of the same code:

# 解説を参考に作成

def solve():

    X = int(eval(input()))

    A, B = 0, 0

    # A と B の差が最も小さい時(A - B = 1)に, ans < 10**9 となるのは

    # -118 <= A <= 119, -119 <= B <= 118 の場合となる.

    # A - B > 1 の場合でも同じ範囲だけ見れば十分となる.

    # A - B < 1 の場合は答えが負になるので, X >= 1 の制約から検討不要.

    for a in range(-118, 119 + 1):

        for b in range(-119, 118 + 1):

            if a ** 5 - b ** 5 == X:

                A, B = a, b

                break

    print((A, B))

if __name__ == '__main__':

    solve()

# 解説を参考に作成
def solve():
    X = int(eval(input()))
    A, B = 0, 0
    for a in range(-200, 200):
        for b in range(-200, 200):
            if a**5 - b**5 == X:
                A, B = a, b
                break
    print((A, B))

if __name__ == "__main__":
    solve()

# 解説を参考に作成
def solve():
    X = int(eval(input()))
    A, B = 0, 0
    # A と B の差が最も小さい時(A - B = 1)に, ans < 10**9 となるのは
    # -118 <= A <= 119, -119 <= B <= 118 の場合となる.
    # A - B > 1 の場合でも同じ範囲だけ見れば十分となる.
    # A - B < 1 の場合は答えが負になるので, X >= 1 の制約から検討不要.
    for a in range(-118, 119 + 1):
        for b in range(-119, 118 + 1):
            if a**5 - b**5 == X:
                A, B = a, b
                break
    print((A, B))

if __name__ == "__main__":
    solve()

+    # A と B の差が最も小さい時(A - B = 1)に, ans < 10**9 となるのは

+    # A - B > 1 の場合でも同じ範囲だけ見れば十分となる.

+    # A - B < 1 の場合は答えが負になるので, X >= 1 の制約から検討不要.


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

# coding: utf-8

import sys

import numpy as np

sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))

N = ir()

V = np.array(lr())

C = np.array(lr())

V -= C

V = V[V>0]

answer = V.sum()

print(answer)

# optimized version of the same code:

# coding: utf-8

import sys

sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))

N = ir()

V = lr()

C = lr()

total = 0

for i in range(N):

    result = V[i] - C[i]

    if result > 0:

        total += result

print(total)

# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = ir()
V = np.array(lr())
C = np.array(lr())
V -= C
V = V[V > 0]
answer = V.sum()
print(answer)

-import numpy as np
-V = np.array(lr())
-C = np.array(lr())
-V -= C
-V = V[V > 0]
-answer = V.sum()
-print(answer)
+V = lr()
+C = lr()
+total = 0
+for i in range(N):
+    result = V[i] - C[i]
+    if result > 0:
+        total += result
+print(total)


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

from math import log2

n = int(eval(input()))

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

ans = 0

for _a in a:

    if _a%2 == 0:

        cnt =0

        while _a%2 == 0:

            _a //= 2

            cnt += 1

        ans += cnt

print((int(ans)))

# optimized version of the same code:

def f(k):

    cnt = 0

    while k%2 == 0:

        k //= 2

        cnt += 1

        # print(k)

        # print("-----")

    return cnt

n = int(eval(input()))

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

ans = 0

for a in A:

    if a%2 == 0:

        ans += f(a)

print(ans)

from math import log2

n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for _a in a:
    if _a % 2 == 0:
        cnt = 0
        while _a % 2 == 0:
            _a //= 2
            cnt += 1
        ans += cnt
print((int(ans)))

def f(k):
    cnt = 0
    while k % 2 == 0:
        k //= 2
        cnt += 1
        # print(k)
        # print("-----")
    return cnt

n = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
for a in A:
    if a % 2 == 0:
        ans += f(a)
print(ans)

-from math import log2
+def f(k):
+    cnt = 0
+    while k % 2 == 0:
+        k //= 2
+        cnt += 1
+        # print(k)
+    return cnt
+
-a = list(map(int, input().split()))
+A = list(map(int, input().split()))
-for _a in a:
-    if _a % 2 == 0:
-        cnt = 0
-        while _a % 2 == 0:
-            _a //= 2
-            cnt += 1
-        ans += cnt
-print((int(ans)))
+for a in A:
+    if a % 2 == 0:
+        ans += f(a)
+print(ans)


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

# coding: utf-8

def solve(*args: str) -> str:

    n, m, k = list(map(int, args[0].split()))

    mod = 998244353

    if m == 1 and n-1 == k:

        return str(1)

    ncr = 1

    p = m*pow(m-1, n-1, mod) % mod

    ret = p

    inv = pow(m-1, mod-2, mod)

    for i in range(1, k+1):

        ncr = (ncr * (n-i)*pow(i, mod-2, mod)) % mod

        p = (p*inv) % mod

        ret += p*ncr % mod

    return str(ret % mod)

if __name__ == "__main__":

    print((solve(*(open(0).read().splitlines()))))

# optimized version of the same code:

# coding: utf-8

def solve(*args: str) -> str:

    n, m, k = list(map(int, args[0].split()))

    mod = 998244353

    if m == 1 and n-1 == k:

        return str(1)

    ncr = 1

    p = m*pow(m-1, n-1, mod) % mod

    ret = p

    iR = [1]*(k+1)

    im = pow(m-1, mod-2, mod)

    for i in range(1, k+1):

        iR[i] = max(1, (-(mod//i) * iR[mod % i]) % mod)

        ncr = (ncr * (n-i)*iR[i]) % mod

        p = (p*im) % mod

        ret += p*ncr % mod

    return str(ret % mod)

if __name__ == "__main__":

    print((solve(*(open(0).read().splitlines()))))

# coding: utf-8
def solve(*args: str) -> str:
    n, m, k = list(map(int, args[0].split()))
    mod = 998244353
    if m == 1 and n - 1 == k:
        return str(1)
    ncr = 1
    p = m * pow(m - 1, n - 1, mod) % mod
    ret = p
    inv = pow(m - 1, mod - 2, mod)
    for i in range(1, k + 1):
        ncr = (ncr * (n - i) * pow(i, mod - 2, mod)) % mod
        p = (p * inv) % mod
        ret += p * ncr % mod
    return str(ret % mod)

if __name__ == "__main__":
    print((solve(*(open(0).read().splitlines()))))

# coding: utf-8
def solve(*args: str) -> str:
    n, m, k = list(map(int, args[0].split()))
    mod = 998244353
    if m == 1 and n - 1 == k:
        return str(1)
    ncr = 1
    p = m * pow(m - 1, n - 1, mod) % mod
    ret = p
    iR = [1] * (k + 1)
    im = pow(m - 1, mod - 2, mod)
    for i in range(1, k + 1):
        iR[i] = max(1, (-(mod // i) * iR[mod % i]) % mod)
        ncr = (ncr * (n - i) * iR[i]) % mod
        p = (p * im) % mod
        ret += p * ncr % mod
    return str(ret % mod)

if __name__ == "__main__":
    print((solve(*(open(0).read().splitlines()))))

-        ncr = (ncr * (n - i) * pow(i, mod - 2, mod)) % mod

+        ncr = (ncr * (n - i) * iR[i]) % mod


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

x = int(eval(input()))

a = 0

b = 0

for i in range(-120, 120):

    for j in range(-120, 120):

        if i ** 5 - j ** 5 == x:

            a = i

            b = j

print((a, b))

# optimized version of the same code:

x = int(eval(input()))

for i in range(-120, 120):

    for j in range(-120, 120):

        if i ** 5 - j ** 5 == x:

            print((i, j))

            exit()

x = int(eval(input()))
a = 0
b = 0
for i in range(-120, 120):
    for j in range(-120, 120):
        if i**5 - j**5 == x:
            a = i
            b = j
print((a, b))

x = int(eval(input()))
for i in range(-120, 120):
    for j in range(-120, 120):
        if i**5 - j**5 == x:
            print((i, j))
            exit()


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import collections as col

def prime(n):

    ans = []

    num = n

    for i in range(2,n+1):

        if i%2==0 and i!=2: continue

        while num%i == 0: num //= i ; ans.append(i)

    return ans

n = int(eval(input()))

mod = 10**9 + 7

primes = []

for i in range(2,n+1): primes += prime(i)

cnt = col.Counter(primes)

ans = 1

for key,val in list(cnt.items()): ans *= (val + 1) ; ans %= mod

print(ans)

# optimized version of the same code:

import collections as col

def prime(n):

    ans = []

    num = n

    for i in range(2,int(n**0.5)+1):

        if i%2==0 and i!=2: continue

        while num%i == 0: num //= i ; ans.append(i)

    if num != 1: ans.append(num)

    return ans

n = int(eval(input()))

mod = 10**9 + 7

primes = []

for i in range(2,n+1): primes += prime(i)

cnt = col.Counter(primes)

ans = 1

for key,val in list(cnt.items()): ans *= (val + 1) ; ans %= mod

print(ans)

import collections as col

def prime(n):
    ans = []
    num = n
    for i in range(2, n + 1):
        if i % 2 == 0 and i != 2:
            continue
        while num % i == 0:
            num //= i
            ans.append(i)
    return ans

n = int(eval(input()))
mod = 10**9 + 7
primes = []
for i in range(2, n + 1):
    primes += prime(i)
cnt = col.Counter(primes)
ans = 1
for key, val in list(cnt.items()):
    ans *= val + 1
    ans %= mod
print(ans)

import collections as col

def prime(n):
    ans = []
    num = n
    for i in range(2, int(n**0.5) + 1):
        if i % 2 == 0 and i != 2:
            continue
        while num % i == 0:
            num //= i
            ans.append(i)
    if num != 1:
        ans.append(num)
    return ans

n = int(eval(input()))
mod = 10**9 + 7
primes = []
for i in range(2, n + 1):
    primes += prime(i)
cnt = col.Counter(primes)
ans = 1
for key, val in list(cnt.items()):
    ans *= val + 1
    ans %= mod
print(ans)

+    for i in range(2, int(n**0.5) + 1):


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import sys

def main():

    input = sys.stdin.readline

    N = int(eval(input()))

    E = [[] for _ in range(N)]

    for i in range(N-1):

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

        a, b = a-1, b-1

        E[a].append((b,i))

        E[b].append((a,i))

    def dfs(s, g):

        par = [(-1,-1)] * N

        par[s] = (s,-1)

        stack = [s]

        while stack:

            v = stack.pop()

            for to, i in E[v]:

                if par[to][0] >= 0: continue

                par[to] = (v, i)

                if to == g: break

                stack.append(to)

        r = set()

        v = g

        while v != s:

            v, i = par[v]

            r.add(i)

        return r

    M = int(eval(input()))

    path = [None] * M

    for i in range(M):

        u, v = list(map(int, input().split()))

        u, v = u-1, v-1

        path[i] = dfs(u, v)

    def calc(s): return 1<<(N-1-len(s))

    i_ans = 0

    for p in range(1, 1<<M):

        is_odd = bin(p).count('1') & 1

        s = set()

        for i in range(M):

            if p&1: s |= path[i]

            p >>= 1

        if is_odd: i_ans += calc(s)

        else: i_ans -= calc(s)

    print(((1<<(N-1)) - i_ans))

if __name__ == '__main__':

    main()

# optimized version of the same code:

import sys

def main():

    input = sys.stdin.readline

    N = int(eval(input()))

    E = [[] for _ in range(N)]

    for i in range(N-1):

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

        a, b = a-1, b-1

        E[a].append((b,i))

        E[b].append((a,i))

    def dfs(s, g):

        par = [(-1,-1)] * N

        par[s] = (s,-1)

        stack = [s]

        while stack:

            v = stack.pop()

            for to, i in E[v]:

                if par[to][0] >= 0: continue

                par[to] = (v, i)

                if to == g: break

                stack.append(to)

        r = set()

        v = g

        while v != s:

            v, i = par[v]

            r.add(i)

        return r

    M = int(eval(input()))

    path = [None] * M

    for i in range(M):

        u, v = list(map(int, input().split()))

        u, v = u-1, v-1

        path[i] = dfs(u, v)

    def calc(s): return 1<<(N-1-len(s))

    i_ans = 0

    for p in range(1, 1<<M):

        is_odd = 0

        s = set()

        for i in range(M):

            if p&1:

                s |= path[i]

                is_odd ^= 1

            p >>= 1

        if is_odd: i_ans += calc(s)

        else: i_ans -= calc(s)

    print(((1<<(N-1)) - i_ans))

if __name__ == '__main__':

    main()

import sys

def main():
    input = sys.stdin.readline
    N = int(eval(input()))
    E = [[] for _ in range(N)]
    for i in range(N - 1):
        a, b = list(map(int, input().split()))
        a, b = a - 1, b - 1
        E[a].append((b, i))
        E[b].append((a, i))

    def dfs(s, g):
        par = [(-1, -1)] * N
        par[s] = (s, -1)
        stack = [s]
        while stack:
            v = stack.pop()
            for to, i in E[v]:
                if par[to][0] >= 0:
                    continue
                par[to] = (v, i)
                if to == g:
                    break
                stack.append(to)
        r = set()
        v = g
        while v != s:
            v, i = par[v]
            r.add(i)
        return r

    M = int(eval(input()))
    path = [None] * M
    for i in range(M):
        u, v = list(map(int, input().split()))
        u, v = u - 1, v - 1
        path[i] = dfs(u, v)

    def calc(s):
        return 1 << (N - 1 - len(s))

    i_ans = 0
    for p in range(1, 1 << M):
        is_odd = bin(p).count("1") & 1
        s = set()
        for i in range(M):
            if p & 1:
                s |= path[i]
            p >>= 1
        if is_odd:
            i_ans += calc(s)
        else:
            i_ans -= calc(s)
    print(((1 << (N - 1)) - i_ans))

if __name__ == "__main__":
    main()

import sys

def main():
    input = sys.stdin.readline
    N = int(eval(input()))
    E = [[] for _ in range(N)]
    for i in range(N - 1):
        a, b = list(map(int, input().split()))
        a, b = a - 1, b - 1
        E[a].append((b, i))
        E[b].append((a, i))

    def dfs(s, g):
        par = [(-1, -1)] * N
        par[s] = (s, -1)
        stack = [s]
        while stack:
            v = stack.pop()
            for to, i in E[v]:
                if par[to][0] >= 0:
                    continue
                par[to] = (v, i)
                if to == g:
                    break
                stack.append(to)
        r = set()
        v = g
        while v != s:
            v, i = par[v]
            r.add(i)
        return r

    M = int(eval(input()))
    path = [None] * M
    for i in range(M):
        u, v = list(map(int, input().split()))
        u, v = u - 1, v - 1
        path[i] = dfs(u, v)

    def calc(s):
        return 1 << (N - 1 - len(s))

    i_ans = 0
    for p in range(1, 1 << M):
        is_odd = 0
        s = set()
        for i in range(M):
            if p & 1:
                s |= path[i]
                is_odd ^= 1
            p >>= 1
        if is_odd:
            i_ans += calc(s)
        else:
            i_ans -= calc(s)
    print(((1 << (N - 1)) - i_ans))

if __name__ == "__main__":
    main()

-        is_odd = bin(p).count("1") & 1
+        is_odd = 0
+                is_odd ^= 1


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

from numpy import*;_,a=open(0);print((*argsort(int32(a.split()))+1))

# optimized version of the same code:

from numpy import *

_, a = open(0)
print((*argsort(int32(a.split())) + 1))

n, a = open(0)
a = a.split()
print((*sorted(list(range(1, int(n) + 1)), key=lambda x: int(a[x - 1]))))

+print((*sorted(list(range(1, int(n) + 1)), key=lambda x: int(a[x - 1]))))


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import sys

from scipy.sparse import csr_matrix

from scipy.sparse.csgraph import floyd_warshall

def solve(N: int, M: int, a: "List[int]", b: "List[int]"):

    answer = 0

    for i in range(M): ## iの辺を消す

        matrix = [[0]*(N) for _ in range(N)]

        for j in range(M):

            if j == i:

                continue

            aa = a[j]-1

            bb = b[j]-1

            matrix[aa][bb] = 1

        dist_matrix = floyd_warshall(csgraph=csr_matrix(matrix), directed=False)

        if dist_matrix[a[i]-1][b[i]-1] == float('inf'):

            answer += 1

    print(answer)

    return

def main():

    def iterate_tokens():

        for line in sys.stdin:

            for word in line.split():

                yield word

    tokens = iterate_tokens()

    N = int(next(tokens))  # type: int

    M = int(next(tokens))  # type: int

    a = [int()] * (M)  # type: "List[int]"

    b = [int()] * (M)  # type: "List[int]"

    for i in range(M):

        a[i] = int(next(tokens))

        b[i] = int(next(tokens))

    solve(N, M, a, b)

if __name__ == '__main__':

    main()

# optimized version of the same code:

#!/usr/bin/env python3

import sys

input = sys.stdin.readline

def INT(): return int(eval(input()))

def MAP(): return list(map(int,input().split()))

def LI(): return list(map(int,input().split()))

class UnionFind():

    def __init__(self, n):

        self.n = n

        self.parents = [-1] * n

    def find(self, x): # 根を探す

        if self.parents[x] < 0:

            return x

        else:

            self.parents[x] = self.find(self.parents[x])

            return self.parents[x]

    def union(self, x, y):

        x = self.find(x)

        y = self.find(y)

        if x == y:

            return

        if self.parents[x] > self.parents[y]:

            x, y = y, x

        self.parents[x] += self.parents[y]

        self.parents[y] = x

    def size(self, x):

        return -self.parents[self.find(x)]

    def same(self, x, y):

        return self.find(x) == self.find(y)

    def members(self, x):

        root = self.find(x)

        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):

        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):

        return len(self.roots())

    def all_group_members(self):

        return {r: self.members(r) for r in self.roots()}

    def __str__(self):

        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():

    N,M=MAP()

    edges = []

    for _ in range(M):

        a,b = MAP()

        edges.append((a-1,b-1))

    answer = 0

    for i in range(M): # i番目の辺を使わない

        uf = UnionFind(N)

        for j in range(M):

            if i == j:

                continue

            a,b = edges[j]

            uf.union(a,b)

        if uf.group_count() > 1:

            answer += 1

    print(answer)

    return

if __name__ == '__main__':

    main()

import sys
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

def solve(N: int, M: int, a: "List[int]", b: "List[int]"):
    answer = 0
    for i in range(M):  ## iの辺を消す
        matrix = [[0] * (N) for _ in range(N)]
        for j in range(M):
            if j == i:
                continue
            aa = a[j] - 1
            bb = b[j] - 1
            matrix[aa][bb] = 1
        dist_matrix = floyd_warshall(csgraph=csr_matrix(matrix), directed=False)
        if dist_matrix[a[i] - 1][b[i] - 1] == float("inf"):
            answer += 1
    print(answer)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]"
    b = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, M, a, b)

if __name__ == "__main__":
    main()

#!/usr/bin/env python3
import sys

input = sys.stdin.readline

def INT():
    return int(eval(input()))

def MAP():
    return list(map(int, input().split()))

def LI():
    return list(map(int, input().split()))

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):  # 根を探す
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return "\n".join("{}: {}".format(r, self.members(r)) for r in self.roots())

def main():
    N, M = MAP()
    edges = []
    for _ in range(M):
        a, b = MAP()
        edges.append((a - 1, b - 1))
    answer = 0
    for i in range(M):  # i番目の辺を使わない
        uf = UnionFind(N)
        for j in range(M):
            if i == j:
                continue
            a, b = edges[j]
            uf.union(a, b)
        if uf.group_count() > 1:
            answer += 1
    print(answer)
    return

if __name__ == "__main__":
    main()

-from scipy.sparse.csgraph import floyd_warshall

-def solve(N: int, M: int, a: "List[int]", b: "List[int]"):

+    return list(map(int, input().split()))

+            self.parents[x] = self.find(self.parents[x])

+        if self.parents[x] > self.parents[y]:

+        self.parents[x] += self.parents[y]

+        return -self.parents[self.find(x)]

+        return self.find(x) == self.find(y)

+        return [i for i in range(self.n) if self.find(i) == root]

+        return [i for i, x in enumerate(self.parents) if x < 0]

+        return {r: self.members(r) for r in self.roots()}

+        return "\n".join("{}: {}".format(r, self.members(r)) for r in self.roots())

-        matrix = [[0] * (N) for _ in range(N)]

-        dist_matrix = floyd_warshall(csgraph=csr_matrix(matrix), directed=False)

-        if dist_matrix[a[i] - 1][b[i] - 1] == float("inf"):

-    a = [int()] * (M)  # type: "List[int]"

-    b = [int()] * (M)  # type: "List[int]"


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

'''

    Auther: ghoshashis545 Ashis Ghosh

    College: jalpaiguri Govt Enggineering College

'''

from os import path

import sys

from functools import cmp_to_key as ctk

from collections import deque,defaultdict as dd

from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right

from itertools import permutations

from datetime import datetime

from math import ceil,sqrt,log,gcd

def ii():return int(eval(input()))

def si():return eval(input())

def mi():return list(map(int,input().split()))

def li():return list(mi())

abc='abcdefghijklmnopqrstuvwxyz'

mod=1000000007

#mod=998244353

inf = float("inf")

vow=['a','e','i','o','u']

dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):

    return ord(i)-ord('a')

file = 0

def solve():

    # for _ in range(ii()):

    n=ii()

    n%=1000

    if n!=0:

        n=1000-n

    print(n)

if __name__ =="__main__":

    if(file):

        if path.exists('input1.txt'):

            sys.stdin=open('input1.txt', 'r')

            sys.stdout=open('output1.txt','w')

        else:

            input=sys.stdin.readline

    solve()

# optimized version of the same code:

'''

    Auther: ghoshashis545 Ashis Ghosh

    College: jalpaiguri Govt Enggineering College

'''

from os import path

import sys

from heapq import heappush,heappop

from functools import cmp_to_key as ctk

from collections import deque,defaultdict as dd

from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right

from itertools import permutations

from datetime import datetime

from math import ceil,sqrt,log,gcd

def ii():return int(eval(input()))

def si():return eval(input())

def mi():return list(map(int,input().split()))

def li():return list(mi())

abc='abcdefghijklmnopqrstuvwxyz'

mod=1000000007

# mod=998244353

inf = float("inf")

vow=['a','e','i','o','u']

dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):

    return ord(i)-ord('a')

file=0

def solve():

    # for _ in range(ii()):

    n=ii()

    n%=1000

    if(n!=0):

        n=1000-n

    print(n)

if __name__ =="__main__":

    if(file):

        if path.exists('input1.txt'):

            sys.stdin=open('input1.txt', 'r')

            sys.stdout=open('output1.txt','w')

        else:

            input=sys.stdin.readline

    solve()

"""
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College
"""
from os import path
import sys
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
    return int(eval(input()))

def si():
    return eval(input())

def mi():
    return list(map(int, input().split()))

def li():
    return list(mi())

abc = "abcdefghijklmnopqrstuvwxyz"
mod = 1000000007
# mod=998244353
inf = float("inf")
vow = ["a", "e", "i", "o", "u"]
dx, dy = [-1, 1, 0, 0], [0, 0, 1, -1]

def bo(i):
    return ord(i) - ord("a")

file = 0

def solve():
    # for _ in range(ii()):
    n = ii()
    n %= 1000
    if n != 0:
        n = 1000 - n
    print(n)

if __name__ == "__main__":
    if file:
        if path.exists("input1.txt"):
            sys.stdin = open("input1.txt", "r")
            sys.stdout = open("output1.txt", "w")
        else:
            input = sys.stdin.readline
    solve()

"""
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College
"""
from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
    return int(eval(input()))

def si():
    return eval(input())

def mi():
    return list(map(int, input().split()))

def li():
    return list(mi())

abc = "abcdefghijklmnopqrstuvwxyz"
mod = 1000000007
# mod=998244353
inf = float("inf")
vow = ["a", "e", "i", "o", "u"]
dx, dy = [-1, 1, 0, 0], [0, 0, 1, -1]

def bo(i):
    return ord(i) - ord("a")

file = 0

def solve():
    # for _ in range(ii()):
    n = ii()
    n %= 1000
    if n != 0:
        n = 1000 - n
    print(n)

if __name__ == "__main__":
    if file:
        if path.exists("input1.txt"):
            sys.stdin = open("input1.txt", "r")
            sys.stdout = open("output1.txt", "w")
        else:
            input = sys.stdin.readline
    solve()


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import sys

from collections import deque

import numpy as np

def main():

    n = int(sys.stdin.readline().rstrip())

    ab = np.array(sys.stdin.read().split(), dtype=np.int64).reshape(-1, 2)

    G = [[] for _ in range(n + 1)]

    for a, b in ab:

        G[a].append(b)

        G[b].append(a)

    parent = np.zeros(n + 1, dtype=np.int64)

    color = np.zeros(n + 1, dtype=np.int64) # color of the edge(parent[y], y)

    q = deque([1]) # root = 1

    while q:

        x = q.popleft()

        ng = color[x]

        c = 1

        for y in G[x]:

            if y == parent[x]:

                continue

            parent[y] = x

            if c == ng:

                c += 1

            color[y] = c

            q.append(y)

            c += 1

    print((np.amax(color)))

    for a, b in ab:

        if a == parent[b]:

            print((color[b]))

        else:

            print((color[a]))

if __name__ == '__main__':

    main()

# optimized version of the same code:

import sys

from collections import deque

def main():

    n = int(sys.stdin.readline().rstrip())

    ab = list(map(int, sys.stdin.read().split()))

    ab = list(zip(ab, ab))

    G = [[] for _ in range(n + 1)]

    for a, b in ab:

        G[a].append(b)

        G[b].append(a)

    q = deque([1]) # root = 1

    parent = [None] * (n + 1)

    color = [0] * (n + 1) # color of the edge(parent[y], y)

    while q:

        x = q.popleft()

        ng = color[x]

        c = 1

        for y in G[x]:

            if y == parent[x]:

                continue

            parent[y] = x

            if c == ng:

                c += 1

            color[y] = c

            q.append(y)

            c += 1

    print((max(color)))

    for a, b in ab:

        if a == parent[b]:

            print((color[b]))

        else:

            print((color[a]))

if __name__ == '__main__':

    main()

import sys
from collections import deque
import numpy as np

def main():
    n = int(sys.stdin.readline().rstrip())
    ab = np.array(sys.stdin.read().split(), dtype=np.int64).reshape(-1, 2)
    G = [[] for _ in range(n + 1)]
    for a, b in ab:
        G[a].append(b)
        G[b].append(a)
    parent = np.zeros(n + 1, dtype=np.int64)
    color = np.zeros(n + 1, dtype=np.int64)  # color of the edge(parent[y], y)
    q = deque([1])  # root = 1
    while q:
        x = q.popleft()
        ng = color[x]
        c = 1
        for y in G[x]:
            if y == parent[x]:
                continue
            parent[y] = x
            if c == ng:
                c += 1
            color[y] = c
            q.append(y)
            c += 1
    print((np.amax(color)))
    for a, b in ab:
        if a == parent[b]:
            print((color[b]))
        else:
            print((color[a]))

if __name__ == "__main__":
    main()

import sys
from collections import deque

def main():
    n = int(sys.stdin.readline().rstrip())
    ab = list(map(int, sys.stdin.read().split()))
    ab = list(zip(ab, ab))
    G = [[] for _ in range(n + 1)]
    for a, b in ab:
        G[a].append(b)
        G[b].append(a)
    q = deque([1])  # root = 1
    parent = [None] * (n + 1)
    color = [0] * (n + 1)  # color of the edge(parent[y], y)
    while q:
        x = q.popleft()
        ng = color[x]
        c = 1
        for y in G[x]:
            if y == parent[x]:
                continue
            parent[y] = x
            if c == ng:
                c += 1
            color[y] = c
            q.append(y)
            c += 1
    print((max(color)))
    for a, b in ab:
        if a == parent[b]:
            print((color[b]))
        else:
            print((color[a]))

if __name__ == "__main__":
    main()

-    ab = np.array(sys.stdin.read().split(), dtype=np.int64).reshape(-1, 2)

+    ab = list(map(int, sys.stdin.read().split()))

-    parent = np.zeros(n + 1, dtype=np.int64)

-    color = np.zeros(n + 1, dtype=np.int64)  # color of the edge(parent[y], y)

+    color = [0] * (n + 1)  # color of the edge(parent[y], y)


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

M=998244353

n,m,k=list(map(int,input().split()))

a=0

c=1

for i in range(k+1):

  a+=c*m*pow(m-1,n-i-1,M)

  c=c*(n-i-1)*pow(i+1,M-2,M)%M

print((a%M))

# optimized version of the same code:


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

N = int(eval(input()))

a = [int(eval(input())) for _ in range(N)]

cnt, i = 0, 0

for j in range(10 ** 6):

    cnt += 1

    if a[i] == 2:

        print(cnt)

        #break

        quit()

    else:

        i = a[i] - 1

print((-1))

# optimized version of the same code:

N = int(eval(input()))

a = [int(eval(input())) for _ in range(N)]

cnt, i = 0, 0

for j in range(len(a)):

    cnt += 1

    if a[i] == 2:

        print(cnt)

        #break

        quit()

    else:

        i = a[i] - 1

print((-1))

N = int(eval(input()))
a = [int(eval(input())) for _ in range(N)]
cnt, i = 0, 0
for j in range(10**6):
    cnt += 1
    if a[i] == 2:
        print(cnt)
        # break
        quit()
    else:
        i = a[i] - 1
print((-1))

N = int(eval(input()))
a = [int(eval(input())) for _ in range(N)]
cnt, i = 0, 0
for j in range(len(a)):
    cnt += 1
    if a[i] == 2:
        print(cnt)
        # break
        quit()
    else:
        i = a[i] - 1
print((-1))

-for j in range(10**6):
+for j in range(len(a)):


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import math

def combinations_count(n, r):

    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def combinations_with_replacement_count(n, r):

    return combinations_count(n + r - 1, r)

def main():

    s = int(eval(input()))

    ans = 0

    n = s // 3

    for i in range(1, n + 1):

        ans += combinations_with_replacement_count(i, 3*(n-i)+s % 3)

    print((ans % (10**9 + 7)))

if __name__ == '__main__':

    main()

# optimized version of the same code:

import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def combinations_with_replacement_count(n, r):
    return combinations_count(n + r - 1, r)

def main():
    s = int(eval(input()))
    ans = 0
    n = s // 3
    for i in range(1, n + 1):
        ans += combinations_with_replacement_count(i, 3 * (n - i) + s % 3)
    print((ans % (10**9 + 7)))

if __name__ == "__main__":
    main()

-    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

-    return combinations_count(n + r - 1, r)

-        ans += combinations_with_replacement_count(i, 3 * (n - i) + s % 3)


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

G_MAX = 40*10

N_MAX = 40

INF = float('inf')

dp = [[[INF]*(G_MAX+1) for _ in range(G_MAX+1)]

      for _ in range(N_MAX+1)]

N,Ma,Mb = list(map(int, input().split()))

a,b,c = [],[],[]

for _ in range(N):

    ai,bi,ci = list(map(int, input().split()))

    a.append(ai)

    b.append(bi)

    c.append(ci)

dp[0][0][0] = 0

from math import isinf

for i in range(N):

    for ca in range(G_MAX+1):

        for cb in range(G_MAX+1):

            if isinf(dp[i][ca][cb]): continue

            dp[i+1][ca][cb] = min(dp[i+1][ca][cb],

                                 dp[i][ca][cb])

            dp[i+1][ca+a[i]][cb+b[i]] = min(dp[i+1][ca+a[i]][cb+b[i]],

                                           dp[i][ca][cb]+c[i])

ans = INF

for ca in range(1,G_MAX+1):

    for cb in range(1,G_MAX+1):

        if ca*Mb==cb*Ma:

            ans = min(ans, dp[N][ca][cb])

if isinf(ans): ans = -1

print(ans)

# optimized version of the same code:

from math import isinf

N, Ma, Mb = list(map(int, input().split()))

a = [0]*N

b = [0]*N

c = [0]*N

for i in range(N):

    a[i],b[i],c[i] = list(map(int, input().split()))

W_MAX = 40*10

dp = [[float('inf')]*(W_MAX+1) for _ in range(W_MAX+1)]

dp[0][0] = 0

for i in range(N):

    for wa in reversed(list(range(W_MAX+1))):

        for wb in reversed(list(range(W_MAX+1))):

            if isinf(dp[wa][wb]): continue

            if wa+a[i]<=W_MAX and wb+b[i]<=W_MAX:

                dp[wa+a[i]][wb+b[i]] = min(dp[wa+a[i]][wb+b[i]],

                                           dp[wa][wb]+c[i])

ans = float('inf')

for wa in range(1, W_MAX+1):

    for wb in range(1, W_MAX+1):

        if wa*Mb == wb*Ma:

            ans = min(ans, dp[wa][wb])

if isinf(ans): ans = -1

print(ans)

G_MAX = 40 * 10
N_MAX = 40
INF = float("inf")
dp = [[[INF] * (G_MAX + 1) for _ in range(G_MAX + 1)] for _ in range(N_MAX + 1)]
N, Ma, Mb = list(map(int, input().split()))
a, b, c = [], [], []
for _ in range(N):
    ai, bi, ci = list(map(int, input().split()))
    a.append(ai)
    b.append(bi)
    c.append(ci)
dp[0][0][0] = 0
from math import isinf

for i in range(N):
    for ca in range(G_MAX + 1):
        for cb in range(G_MAX + 1):
            if isinf(dp[i][ca][cb]):
                continue
            dp[i + 1][ca][cb] = min(dp[i + 1][ca][cb], dp[i][ca][cb])
            dp[i + 1][ca + a[i]][cb + b[i]] = min(
                dp[i + 1][ca + a[i]][cb + b[i]], dp[i][ca][cb] + c[i]
            )
ans = INF
for ca in range(1, G_MAX + 1):
    for cb in range(1, G_MAX + 1):
        if ca * Mb == cb * Ma:
            ans = min(ans, dp[N][ca][cb])
if isinf(ans):
    ans = -1
print(ans)

from math import isinf

N, Ma, Mb = list(map(int, input().split()))
a = [0] * N
b = [0] * N
c = [0] * N
for i in range(N):
    a[i], b[i], c[i] = list(map(int, input().split()))
W_MAX = 40 * 10
dp = [[float("inf")] * (W_MAX + 1) for _ in range(W_MAX + 1)]
dp[0][0] = 0
for i in range(N):
    for wa in reversed(list(range(W_MAX + 1))):
        for wb in reversed(list(range(W_MAX + 1))):
            if isinf(dp[wa][wb]):
                continue
            if wa + a[i] <= W_MAX and wb + b[i] <= W_MAX:
                dp[wa + a[i]][wb + b[i]] = min(
                    dp[wa + a[i]][wb + b[i]], dp[wa][wb] + c[i]
                )
ans = float("inf")
for wa in range(1, W_MAX + 1):
    for wb in range(1, W_MAX + 1):
        if wa * Mb == wb * Ma:
            ans = min(ans, dp[wa][wb])
if isinf(ans):
    ans = -1
print(ans)

-dp = [[[INF] * (G_MAX + 1) for _ in range(G_MAX + 1)] for _ in range(N_MAX + 1)]

-N, Ma, Mb = list(map(int, input().split()))

-    ai, bi, ci = list(map(int, input().split()))

+N, Ma, Mb = list(map(int, input().split()))

+    a[i], b[i], c[i] = list(map(int, input().split()))

+dp = [[float("inf")] * (W_MAX + 1) for _ in range(W_MAX + 1)]

+    for wa in reversed(list(range(W_MAX + 1))):

+        for wb in reversed(list(range(W_MAX + 1))):

-            ans = min(ans, dp[N][ca][cb])

+            if wa + a[i] <= W_MAX and wb + b[i] <= W_MAX:

+                dp[wa + a[i]][wb + b[i]] = min(


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

from itertools import product

n = int(eval(input()))

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

count = 0

for C in product((-1, 0, 1), repeat=n):

  total = 1

  for a, c in zip(A, C):

    total *= (a + c)

  if total % 2 == 0:

    count += 1

print(count)

# optimized version of the same code:

n = int(eval(input()))

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

count = 1

for a in A:

  count *= 2 if a % 2 == 0 else 1

print((3 ** n - count))

from itertools import product

n = int(eval(input()))
A = list(map(int, input().split()))
count = 0
for C in product((-1, 0, 1), repeat=n):
    total = 1
    for a, c in zip(A, C):
        total *= a + c
    if total % 2 == 0:
        count += 1
print(count)

n = int(eval(input()))
A = list(map(int, input().split()))
count = 1
for a in A:
    count *= 2 if a % 2 == 0 else 1
print((3**n - count))

-for C in product((-1, 0, 1), repeat=n):


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

X = int(eval(input()))

gojyous = []

for i in range(-200, 201):

    gojyous.append(i ** 5)

#print(gojyous)

for i in range(-200,201):

    for j in range(-200,201):

        if(X == (int(i**5) - int(j**5))):

            print((i, j))

            exit()

# optimized version of the same code:

import sys

X= int(eval(input()))

#添字の最大値を算出

a = 1

b = 0

dif = 0

while dif < 10**9:

    a += 1

    b += 1

    dif = a ** 5 - b ** 5

loop_sequence = a - 1

for i in range(-(loop_sequence),loop_sequence):

	for j in range(-(loop_sequence),loop_sequence):

		if(X == i ** 5 - j ** 5):

			print((i,j))

			sys.exit()

X = int(eval(input()))
gojyous = []
for i in range(-200, 201):
    gojyous.append(i**5)
# print(gojyous)
for i in range(-200, 201):
    for j in range(-200, 201):
        if X == (int(i**5) - int(j**5)):
            print((i, j))
            exit()

import sys

X = int(eval(input()))
# 添字の最大値を算出
a = 1
b = 0
dif = 0
while dif < 10**9:
    a += 1
    b += 1
    dif = a**5 - b**5
loop_sequence = a - 1
for i in range(-(loop_sequence), loop_sequence):
    for j in range(-(loop_sequence), loop_sequence):
        if X == i**5 - j**5:
            print((i, j))
            sys.exit()

+# 添字の最大値を算出

+for i in range(-(loop_sequence), loop_sequence):

+    for j in range(-(loop_sequence), loop_sequence):


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import sys

sys.setrecursionlimit(2147483647)

INF=float("inf")

MOD=10**9+7

input=lambda :sys.stdin.readline().rstrip()

def resolve():

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

    WV=[tuple(map(int,input().split())) for _ in range(n)]

    V=100000

    dp=[INF]*(V+1)

    dp[0]=0

    for w,v in WV:

        for x in range(V,-1,-1):

            if(x+v<=V):

                dp[x+v]=min(dp[x+v],dp[x]+w)

    for x in range(V,-1,-1):

        if(dp[x]<=W):

            print(x)

            return

resolve()

# optimized version of the same code:

import sys

INF = 1 << 60

MOD = 10**9 + 7 # 998244353

sys.setrecursionlimit(2147483647)

input = lambda:sys.stdin.readline().rstrip()

def resolve():

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

    dp = [INF] * (n * 1001 + 1)

    dp[0] = 0

    for _ in range(n):

        w, v = list(map(int, input().split()))

        for v0 in range(n * 1001, -1, -1):

            if dp[v0] == INF:

                continue

            if v + v0 <= n * 1001:

                dp[v + v0] = min(dp[v + v0], dp[v0] + w)

    for v in range(n * 1001, -1, -1):

        if dp[v] <= W:

            print(v)

            return

resolve()

import sys

sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7
input = lambda: sys.stdin.readline().rstrip()

def resolve():
    n, W = list(map(int, input().split()))
    WV = [tuple(map(int, input().split())) for _ in range(n)]
    V = 100000
    dp = [INF] * (V + 1)
    dp[0] = 0
    for w, v in WV:
        for x in range(V, -1, -1):
            if x + v <= V:
                dp[x + v] = min(dp[x + v], dp[x] + w)
    for x in range(V, -1, -1):
        if dp[x] <= W:
            print(x)
            return

resolve()

import sys

INF = 1 << 60
MOD = 10**9 + 7  # 998244353
sys.setrecursionlimit(2147483647)
input = lambda: sys.stdin.readline().rstrip()

def resolve():
    n, W = list(map(int, input().split()))
    dp = [INF] * (n * 1001 + 1)
    dp[0] = 0
    for _ in range(n):
        w, v = list(map(int, input().split()))
        for v0 in range(n * 1001, -1, -1):
            if dp[v0] == INF:
                continue
            if v + v0 <= n * 1001:
                dp[v + v0] = min(dp[v + v0], dp[v0] + w)
    for v in range(n * 1001, -1, -1):
        if dp[v] <= W:
            print(v)
            return

resolve()

-    WV = [tuple(map(int, input().split())) for _ in range(n)]

-                dp[x + v] = min(dp[x + v], dp[x] + w)

+        w, v = list(map(int, input().split()))


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

from collections import defaultdict

def main():

    _ = int(eval(input()))

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

    """

    for j>i, j-i = Ai + Aj

    i + Ai = j -Aj

    """

    L = defaultdict(int)

    R = defaultdict(int)

    for i, height in enumerate(heights):

        L[i + height] += 1

        R[i - height] += 1

    total_count = 0

    for x, count_l in list(L.items()):

        if x in R:

            count_r = R[x]

            total_count += count_l * count_r

    print(total_count)

if __name__ == "__main__":

    main()

# optimized version of the same code:

from collections import defaultdict

def main():

    N = int(eval(input()))

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

    """

    for j>i, j-i = Ai + Aj

    i + Ai = j -Aj

    """

    L = defaultdict(int)

    R = defaultdict(int)

    for i, height in enumerate(heights):

        if i + height < N:

            L[i + height] += 1

        if i - height > 0:

            R[i - height] += 1

    total_count = 0

    for x, count_l in list(L.items()):

        if x in R:

            count_r = R[x]

            total_count += count_l * count_r

    print(total_count)

if __name__ == "__main__":

    main()

-    _ = int(eval(input()))
+    N = int(eval(input()))
-        L[i + height] += 1
-        R[i - height] += 1
+        if i + height < N:
+            L[i + height] += 1
+        if i - height > 0:
+            R[i - height] += 1


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

import sys

readline = sys.stdin.readline

sys.setrecursionlimit(10**8)

mod = 10**9+7

#mod = 998244353

INF = 10**18

eps = 10**-7

m,n,k = list(map(int,readline().split()))

def comb(n, r, mod):

    r = min(r, n-r)

    mol = 1

    deno = 1

    for i in range(1, r+1):

        mol = mol * (n-r+i) % mod

        deno = deno * i % mod

    ret = mol * pow(deno, mod-2, mod) % mod

    return ret

def f1(x,y,a,b):

    return (a+b-x-y)*(a-x+1)*(b-y+1)//2

def f2(x,a):

    return (a-x)*(a-x+1)//2

ans = 0

for x in range(1,n+1):

    for y in range(1,m+1):

        a = n-x+1

        b = m-y+1

        c = m*(a*(a-1)+x*(x-1))

        d = n*(b*(b-1)+y*(y-1))

        ans += (c+d)//2

        ans %= mod

ans = (ans * comb(m*n-2,k-2,mod))%mod

ans = ans*pow(2,mod-2,mod)%mod

print(ans)

# optimized version of the same code:

import sys

readline = sys.stdin.readline

sys.setrecursionlimit(10**8)

mod = 10**9+7

#mod = 998244353

INF = 10**18

eps = 10**-7

m,n,k = list(map(int,readline().split()))

def comb(n, r, mod):

    r = min(r, n-r)

    mol = 1

    deno = 1

    for i in range(1, r+1):

        mol = mol * (n-r+i) % mod

        deno = deno * i % mod

    ret = mol * pow(deno, mod-2, mod) % mod

    return ret

ans = m*n*(m+n)*(m*n-1)//3

ans = (ans * comb(m*n-2,k-2,mod))%mod

ans = ans*pow(2,mod-2,mod)%mod

print(ans)

import sys

readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9 + 7
# mod = 998244353
INF = 10**18
eps = 10**-7
m, n, k = list(map(int, readline().split()))

def comb(n, r, mod):
    r = min(r, n - r)
    mol = 1
    deno = 1
    for i in range(1, r + 1):
        mol = mol * (n - r + i) % mod
        deno = deno * i % mod
    ret = mol * pow(deno, mod - 2, mod) % mod
    return ret

def f1(x, y, a, b):
    return (a + b - x - y) * (a - x + 1) * (b - y + 1) // 2

def f2(x, a):
    return (a - x) * (a - x + 1) // 2

ans = 0
for x in range(1, n + 1):
    for y in range(1, m + 1):
        a = n - x + 1
        b = m - y + 1
        c = m * (a * (a - 1) + x * (x - 1))
        d = n * (b * (b - 1) + y * (y - 1))
        ans += (c + d) // 2
        ans %= mod
ans = (ans * comb(m * n - 2, k - 2, mod)) % mod
ans = ans * pow(2, mod - 2, mod) % mod
print(ans)

import sys

readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9 + 7
# mod = 998244353
INF = 10**18
eps = 10**-7
m, n, k = list(map(int, readline().split()))

def comb(n, r, mod):
    r = min(r, n - r)
    mol = 1
    deno = 1
    for i in range(1, r + 1):
        mol = mol * (n - r + i) % mod
        deno = deno * i % mod
    ret = mol * pow(deno, mod - 2, mod) % mod
    return ret

ans = m * n * (m + n) * (m * n - 1) // 3
ans = (ans * comb(m * n - 2, k - 2, mod)) % mod
ans = ans * pow(2, mod - 2, mod) % mod
print(ans)


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

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

div =[]

for i in range(2,int(M**(1/2))+2):

    cur = 0

    while M%i==0:

        M = M//i

        cur += 1

    if cur >=1:

        div.append(cur)

if M>1: div.append(1)

div.sort()

mod = 10**9+7

frac = [1]*(N+50)

num = len(frac)

for i in range(len(frac)-1):

    frac[i+1] = frac[i]*(i+1)%mod

finv = [1] * (N+50)

finv[-1] = pow(frac[-1], mod-2, mod)

for i in range(1, num):

  finv[num-1-i] = finv[num-i] * (num-i) % mod

ans = 1

for i in div:

    ans = ans * frac[N+i-1]*finv[N-1]*finv[i]%mod

print(ans)

# optimized version of the same code:

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

div = []

for i in range(2,int(M**(1/2))+2):

    cur = 0

    while M%i==0:

        M//=i

        cur += 1

    if cur >=1:

        div.append(cur)

if M>1:div.append(1)

div.sort()

mod = 10**9+7

frac = [1]*(N+50)

num=len(frac)

for i in range(num-1):

    frac[i+1] = frac[i]*(i+1)%mod

finv = [1]*(N+50)

finv[-1] = pow(frac[-1],mod-2,mod)

ans = 1

for i in range(1,num):

    finv[num-1-i] = finv[num-i]*(num-i)%mod

for i in div:

    ans  =ans*frac[N+i-1]*finv[N-1]*finv[i]%mod

print(ans)

N, M = list(map(int, input().split()))
div = []
for i in range(2, int(M ** (1 / 2)) + 2):
    cur = 0
    while M % i == 0:
        M = M // i
        cur += 1
    if cur >= 1:
        div.append(cur)
if M > 1:
    div.append(1)
div.sort()
mod = 10**9 + 7
frac = [1] * (N + 50)
num = len(frac)
for i in range(len(frac) - 1):
    frac[i + 1] = frac[i] * (i + 1) % mod
finv = [1] * (N + 50)
finv[-1] = pow(frac[-1], mod - 2, mod)
for i in range(1, num):
    finv[num - 1 - i] = finv[num - i] * (num - i) % mod
ans = 1
for i in div:
    ans = ans * frac[N + i - 1] * finv[N - 1] * finv[i] % mod
print(ans)

N, M = list(map(int, input().split()))
div = []
for i in range(2, int(M ** (1 / 2)) + 2):
    cur = 0
    while M % i == 0:
        M //= i
        cur += 1
    if cur >= 1:
        div.append(cur)
if M > 1:
    div.append(1)
div.sort()
mod = 10**9 + 7
frac = [1] * (N + 50)
num = len(frac)
for i in range(num - 1):
    frac[i + 1] = frac[i] * (i + 1) % mod
finv = [1] * (N + 50)
finv[-1] = pow(frac[-1], mod - 2, mod)
ans = 1
for i in range(1, num):
    finv[num - 1 - i] = finv[num - i] * (num - i) % mod
for i in div:
    ans = ans * frac[N + i - 1] * finv[N - 1] * finv[i] % mod
print(ans)

-        M = M // i
+        M //= i
-for i in range(len(frac) - 1):
+for i in range(num - 1):
+ans = 1
-ans = 1


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

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

# print(a, b, c, x, y)

ans = 10000 * (10 **5) + 7

c_max = 0

if x > y:

  c_max = x * 2

else:

  c_max = y * 2

for cc in range(c_max+1):

  ac = x - (cc // 2)

  bc = y - (cc // 2)

  if ac < 0:

    ac = 0

  if bc < 0:

    bc = 0

  price = ac * a + bc * b + cc * c

  # print('price: {}, ac: {}, bc: {}, cc: {}'.format(price, ac, bc, cc))

  ans = min(ans, price)

print(ans)

# optimized version of the same code:

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

# print(a, b, c, x, y)

ans = 10000 * (10 **5) + 7

c_max = 0

if x > y:

  c_max = x * 2

else:

  c_max = y * 2

for cc in range(0, c_max+1, 2):

  ac = x - (cc // 2)

  bc = y - (cc // 2)

  if ac < 0:

    ac = 0

  if bc < 0:

    bc = 0

  price = ac * a + bc * b + cc * c

  # print('price: {}, ac: {}, bc: {}, cc: {}'.format(price, ac, bc, cc))

  ans = min(ans, price)

print(ans)

a, b, c, x, y = list(map(int, input().split()))
# print(a, b, c, x, y)
ans = 10000 * (10**5) + 7
c_max = 0
if x > y:
    c_max = x * 2
else:
    c_max = y * 2
for cc in range(c_max + 1):
    ac = x - (cc // 2)
    bc = y - (cc // 2)
    if ac < 0:
        ac = 0
    if bc < 0:
        bc = 0
    price = ac * a + bc * b + cc * c
    # print('price: {}, ac: {}, bc: {}, cc: {}'.format(price, ac, bc, cc))
    ans = min(ans, price)
print(ans)

a, b, c, x, y = list(map(int, input().split()))
# print(a, b, c, x, y)
ans = 10000 * (10**5) + 7
c_max = 0
if x > y:
    c_max = x * 2
else:
    c_max = y * 2
for cc in range(0, c_max + 1, 2):
    ac = x - (cc // 2)
    bc = y - (cc // 2)
    if ac < 0:
        ac = 0
    if bc < 0:
        bc = 0
    price = ac * a + bc * b + cc * c
    # print('price: {}, ac: {}, bc: {}, cc: {}'.format(price, ac, bc, cc))
    ans = min(ans, price)
print(ans)

-for cc in range(c_max + 1):
+for cc in range(0, c_max + 1, 2):


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

N = int(eval(input()))

name = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}

march = "MARCH"

for _ in range(N):

  S = eval(input())

  if(S[0] in name):

    name[S[0]] += 1

ans = 0

for i in range(3):

  for j in range(i+1,4):

    for k in range(j+1,5):

      ans += name[march[i]] * name[march[j]] * name[march[k]]

print(ans)

# optimized version of the same code:

N = int(eval(input()))

S = [eval(input()) for _ in range(N)]

head = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}

march = "MARCH"

for s in S:

  if(s[0] in head):

    head[s[0]] += 1

ans = 0

for i in range(3):

  for j in range(i+1,4):

    for k in range(j+1,5):

      ans += head[march[i]] * head[march[j]] * head[march[k]]

print(ans)

N = int(eval(input()))
name = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0}
march = "MARCH"
for _ in range(N):
    S = eval(input())
    if S[0] in name:
        name[S[0]] += 1
ans = 0
for i in range(3):
    for j in range(i + 1, 4):
        for k in range(j + 1, 5):
            ans += name[march[i]] * name[march[j]] * name[march[k]]
print(ans)

N = int(eval(input()))
S = [eval(input()) for _ in range(N)]
head = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0}
march = "MARCH"
for s in S:
    if s[0] in head:
        head[s[0]] += 1
ans = 0
for i in range(3):
    for j in range(i + 1, 4):
        for k in range(j + 1, 5):
            ans += head[march[i]] * head[march[j]] * head[march[k]]
print(ans)

-            ans += name[march[i]] * name[march[j]] * name[march[k]]

+            ans += head[march[i]] * head[march[j]] * head[march[k]]


Input:
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')

# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)

# slower version:

n = int(eval(input()))

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

ans = [i for i in range(n)]

a1 = sorted(a)

for i in range(n):

    num = a[i]

    ans[num - 1] = str(i + 1)

print((' '.join(ans)))

# optimized version of the same code:

n = int(eval(input()))

# n,k = map(int,input().split())

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

ans = [0 for _ in range(n)]

for i in range(n):

  ans[a[i] - 1] = str(i + 1)

print((" ".join(ans)))

n = int(eval(input()))
a = list(map(int, input().split()))
ans = [i for i in range(n)]
a1 = sorted(a)
for i in range(n):
    num = a[i]
    ans[num - 1] = str(i + 1)
print((" ".join(ans)))

n = int(eval(input()))
# n,k = map(int,input().split())
a = list(map(int, input().split()))
ans = [0 for _ in range(n)]
for i in range(n):
    ans[a[i] - 1] = str(i + 1)
print((" ".join(ans)))

+# n,k = map(int,input().split())
-ans = [i for i in range(n)]
-a1 = sorted(a)
+ans = [0 for _ in range(n)]
-    num = a[i]
-    ans[num - 1] = str(i + 1)
+    ans[a[i] - 1] = str(i + 1)