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

from collections import deque

N, M = map(int, input().split())
X = [ list(map(int, input().split())) for _ in range(M)]

Y = [ [] for _ in range(N)]
for x in X:
    Y[x[0]-1].append((x[0], x[1], x[2]))
    Y[x[1]-1].append((x[1], x[0], x[2]))
# print(Y)

visited = [False] * N
count = 0
que = deque()

for i in range(len(Y)):
    if len(Y[i]) == 0:
        visited[i] = True
        count +=1

while True:
    if not False in visited:
        break
    count += 1
    que.append(visited.index(False))
    
    while len(que)>0:
        v = que.popleft()
        visited[v] = True
        for y in Y[v]:
            if not visited[y[1]-1]:
                que.append(y[1]-1)
    

print(count)

### FIXED CODE ###

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        
    def find_root(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.find_root(self.par[x])
        return self.par[x]
    
    def union(self, x, y):
        x_root = self.find_root(x)
        y_root = self.find_root(y)
        if x_root != y_root:
            if self.rank[x_root] < self.rank[y_root]:
                x_root, y_root = y_root, x_root
            if self.rank[x_root] == self.rank[y_root]:
                self.rank[x_root] += 1
            self.par[y_root] = x_root
            
    def is_same(self, x, y):
        x_root = self.find_root(x)
        y_root = self.find_root(y)
        return x_root == y_root
        
N, M = map(int, input().split())
X = [ list(map(int, input().split())) for _ in range(M)]

uf = UnionFind(N)
for x in X:
    uf.union(x[0]-1, x[1]-1)
    
roots = [ uf.find_root(i) for i in range(N)]
print(len(set(roots)))
### BUGGY CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
sort_h=sorted(h,reverse=True)
if(n<k):
    print('0')
elif(k==0):
    print(sum(h))
else:
    for i in range(k):
        sort_h.pop(0)
    print(sum(sort_h))
    


### FIXED CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
sort_h=sorted(h,reverse=True)
if(n<k):
    print('0')
elif(k==0):
    print(sum(h))
else:
    print(sum(sort_h[k:]))
### BUGGY CODE ###

from statistics import mean,median

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

med=median(a)

a1=[i for i in a if i <= med]
a2=[i for i in a if i >= med]
#print(a1)
#print(a2)

for i in range(n):
  if a[i]<min(a2):
    print(min(a2))
  else:
    print(max(a1))

#if a[0] < median(a)
 

### FIXED CODE ###

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

b=sorted(a)

for i in range(n):
  if a[i]<=b[int(n/2)-1]:
    print(b[int(n/2)])
  else:
    print(b[int(n/2)-1])
### BUGGY CODE ###

s1 = list(input())
s2 = list(input())
n = len(s1)
m = len(s2)
dp = [[0]*(m+1) for _ in range(n+1)]
for i in range(1,n+1):
    for j in range(1, m+1):
        if s1[i-1] == s2[j-1]:
            dp[i][j] = 1 + dp[i-1][j-1]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])
res = []
i, j = n, m
while i > 0 and j > 0:
    if dp[i][j] == dp[i][j-1]:
        j -= 1
    elif dp[i][j] == dp[i-1][j]:
        i -= 1
    else:
        res.append(s1[i-1])
        i -= 1
        j -= 1
print(''.join(res[::-1]))

### FIXED CODE ###

s1 = list(input())
s2 = list(input())
n = len(s1)
m = len(s2)
dp = [[0]*(m+1) for _ in range(n+1)]
for i in range(1,n+1):
    for j in range(1, m+1):
        if s1[i-1] == s2[j-1]:
            dp[i][j] = 1 + dp[i-1][j-1]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])
res = []
i, j = n, m
while i > 0 and j > 0:
    if dp[i][j] == dp[i][j-1]:
        j -= 1
    elif dp[i][j] == dp[i-1][j]:
        i -= 1
    else:
        res.append(s1[i-1])
        i -= 1
        j -= 1
print(''.join(res[::-1]))
### BUGGY CODE ###

import collections
n = int(input())
que = collections.deque()
for _ in range(n):
    command = input()
    if 'insert' in command:
        command, num = command.split()
        que.appendleft(int(num))
    elif 'deleteFirst' in command:
        que.popleft()
    elif 'deleteLast' in command:
        que.pop()
    elif 'delete' in command:
        command, num = command.split()
        if int(num) in que:
            que.remove(int(num))
print(' '.join(map(str, que)))

### FIXED CODE ###

import sys
import collections
n = int(input())
que = collections.deque()

for _ in range(n):
    command = sys.stdin.readline()
    if 'i' == command[0]:
        command, num = command.split()
        que.appendleft(num)
    elif 'deleteFirst\n' == command:
        que.popleft()
    elif 'deleteLast\n' == command:
        que.pop()
    else:
        command, num = command.split()
        try:
            que.remove(num)
        except ValueError:
            pass
print(' '.join(map(str, que)))
### BUGGY CODE ###

A,B = map(int, input().split())
ans = A
 
for n in range(A+1,B+1):
    ans = ans ^ n
    
print(ans)

### FIXED CODE ###

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

def F0(n):
    if n%4 == 1:
        return 1
    if n%4 == 2:
        return n + 1
    if n%4 == 3:
        return 0
    if n%4 == 0:
        return n
    if n == 0:
        return 0


print(F0(A-1)^F0(B))
### BUGGY CODE ###

from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial, log, log10, log2
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
from datetime import datetime as dt

def main():
  n = int(readline())
  S = []
  for _ in range(n):
    s = sorted(input())
    S.append(s)
  ans = 0
  for i in range(n-1):
    for j in range(i+1, n):
      if S[i]==S[j]:
        ans+=1
  print(ans)
  
  
if __name__ == '__main__':
  main()

### FIXED CODE ###

from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial, log, log10, log2
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
from datetime import datetime as dt

def main():
  n = int(readline())
  S = []
  for _ in range(n):
    S.append(''.join(sorted(input())))
  counter = Counter(S)
  ans = 0
  for i in counter.values():
    ans +=  i*(i-1)/2
  print(int(ans))
  
if __name__ == '__main__':
  main()
### BUGGY CODE ###

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

# process
ans = 0
pmod = 0
for i in range(N-1):
    mod = int(S[i])%P
    if mod == 0:
        ans += 1
    pmod = mod

    for j in range(i+1, N):
        mod = (int(S[j])+pmod*10)%P
        if mod == 0:
            ans += 1
        pmod = mod

if int(S[-1])%P == 0:
    ans += 1

# output
print(ans)


### FIXED CODE ###

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

# process
ans = 0
if P == 2 or P == 5:
    # 1桁目がPで割り切れる数をカウント
    for i in range(N):
        if int(S[i]) % P == 0:
            ans += i+1

else:
    cnt = [0]*P # S[i:N]%Pの結果をカウント
    num = 0
    tenPow = 1
    for i in reversed(range(N)):
        num = (num + int(S[i])*tenPow)%P
        tenPow = tenPow*10%P
        cnt[num] += 1

    ans += cnt[0]
    for c in cnt:
        ans += c*(c-1)//2 # c=0,1のときは0加算

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

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n, m = map(int, input().split())
edges = [[]for _ in range(n)]
for _ in range(m):
    x, y = map(lambda x: int(x)-1, input().split())
    edges[x].append(y)


def dfs(v, parent):
    visited[v] = 1
    for v2 in edges[v]:
        if v2 == parent:
            continue
        dfs(v2, v)
        if dist[v] >= dist[v2]+1:
            continue
        dist[v] = dist[v2]+1


dist = [0]*n
visited = [0]*n

for i in range(n):
    if visited[i]:
        continue
    dfs(i, -1)

print(max(dist))


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
    x, y = list(map(lambda x: int(x)-1, input().split()))
    edges[x].append(y)


def memoize(f):
    memo = dict()

    def memoized(*args):
        if args in memo.keys():
            return memo[args]
        else:
            memo[args] = f(*args)
            return memo[args]
    return memoized

@memoize
def longest_path(v):
    retval = 0
    for v2 in edges[v]:
        retval = max(retval, longest_path(v2)+1)
    return retval


ans = 0
for i in range(n):
    ans = max(ans, longest_path(i))
print(ans)
### BUGGY CODE ###

y=0
x=float(input())
i=100.0
while i<=x:
    i=i+(i*(1//100))
    y=y+1
 
print(y)

### FIXED CODE ###

y=0
x=int(input())
i=100
while i<x:
    i+=i//100
    y=y+1
 
print(y)
### BUGGY CODE ###

n,k = map(int, input().split())
mi = n
loop = True

if n%k==0:
  mi = 0
  loop = False

while loop:
  loop = False
  if mi > abs(n-k):
    loop = True
    n = abs(n-k)
    mi = n

print(mi)

### FIXED CODE ###

n,k = map(int, input().split())
mi = n%k
if mi > abs(mi-k):
  print(abs(mi-k))
else:
  print(mi)
### BUGGY CODE ###

# coding: utf-8

n = int(input())
a = [int(x) for x in input().split()]

count = 0

for i in range(0, n):
    for j in range(i, n):
        xor_result = 0
        sum_result = 0
        result_bool = True
        for x in a[i:j+1]:
            if sum_result & x != 0:
                result_bool = False
                break
            xor_result ^= x
            sum_result += x
        if xor_result == sum_result and result_bool:
            count += 1

print(count)

### FIXED CODE ###

# coding: utf-8

n = int(input())
a = [int(x) for x in input().split()]

count = 0
xor_result = 0
sum_result = 0
r = 0

for l in range(0, n):
    while r < n:
        x = a[r]
        if sum_result & x != 0:
            break
        xor_result ^= x
        sum_result += x
        r += 1
    count += r - l
    xor_result ^= a[l]
    sum_result -= a[l]

print(count)
### BUGGY CODE ###

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

for i in range(a,b+1):
  num+=1
  
if a>0 and b>0 or a<0 and b<0 and num%2==0:
  print("Positive")
  
elif a<0 and b<0 and num%1==0 or a<0 and b<0:
  print("Negative")
  
else:
  print("Zero")

### FIXED CODE ###

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

if a%2==0 and b%2==1 or a%2==1 and b%2==0:
  num=1
  
if a>0 and b>0 or a<0 and b<0 and num==1:
  print("Positive")
  
elif a<0 and b<0 and num==0 or a<0 and b<0:
  print("Negative")
  
else:
  print("Zero")
### BUGGY CODE ###

#!/usr/bin/env python3
# coding=utf-8

import sys

import numpy as np

n, k = map(int, sys.stdin.readline().strip().split(" "))
xyc = [l.strip().split(" ") for l in sys.stdin.readlines()]
xy = [tuple((int(_x), int(_y) if _c == "W" else int(_y) + k)) for (_x, _y, _c) in xyc]
xy = [tuple((_x % (2 * k), _y % (2 * k))) for (_x, _y) in xy]

ans = np.zeros((2 * k, 2 * k), dtype=np.int32)
for _x, _y in xy:
    if (_x - k + 0.5) * (_y - k + 0.5) > 0:
        _x %= k
        _y %= k
        ans[_x, _y] += 2
        ans[_x + k, _y] -= 2
        ans[_x, _y + k] -= 2
        ans[_x + k, _y + k] += 2
        ans[_x + k, 0] += 1
        ans[0, _y + k] += 1
        ans[0, 0] += 1
        ans[_x, 0] -= 1
        ans[0, _y] -= 1
    else:
        _x %= k
        _y %= k
        ans[_x, _y] -= 2
        ans[_x + k, _y] += 2
        ans[_x, _y + k] += 2
        ans[_x + k, _y + k] -= 2
        ans[_x + k, 0] -= 1
        ans[0, _y + k] -= 1
        ans[_x, 0] += 1
        ans[0, _y] += 1
print(np.max(ans.cumsum(axis=1).cumsum(axis=0)))

### FIXED CODE ###

import numpy as np
N, K = map(int, input().split())
ub = K * 2
b = [[0 for j in range(ub + 1)] for i in range(ub + 1)]
ADD = {"B": 0, "W": K}


def create_bound(p, K, ub):
    if p - K + 1 >= 0:
        return [(p - K + 1, p + 1)]
    else:
        return [(0, p + 1), ((p - K + 1) % ub, ub)]


for i in range(N):
    x, y, c = input().split()
    nx = int(x) % ub
    ny = (int(y) + ADD[c]) % ub
    for add in [0, K]:
        for xlb, xub in create_bound((nx + add) % ub, K, ub):
            for ylb, yub in create_bound((ny + add) % ub, K, ub):
                b[xlb][ylb] += 1
                b[xlb][yub] -= 1
                b[xub][ylb] -= 1
                b[xub][yub] += 1

b_arr = np.array(b)
for i in range(ub):
    b_arr[i + 1, :] += b_arr[i, :]
for j in range(ub):
    b_arr[:, j + 1] += b_arr[:, j]
print(b_arr.max())
### BUGGY CODE ###

from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline

def solve():
    MOD = 998244353
    INF = float('inf')

    N = int(input())
    XDs = [tuple(map(int, input().split())) for _ in range(N)] + [(10**12, 0)]

    XDs.sort()
    Xs = [X for X, D in XDs]

    def max2(x, y): return x if x >= y else y
    def makeBIT(numEle):
        numPow2 = 2 ** (numEle-1).bit_length()
        data = [-INF] * (numPow2+1)
        return data, numPow2
    def setInit(As):
        for iB, A in enumerate(As, 1):
            data[iB] = A
        for iB in range(1, numPow2):
            i = iB + (iB & -iB)
            data[i] = max2(data[i], data[iB])
    def setValue(iA, A):
        iB = iA + 1
        while iB <= numPow2:
            data[iB] = max2(data[iB], A)
            iB += iB & -iB
    def getMax(iA):
        iB = iA + 1
        ans = -INF
        while iB > 0:
            ans = max2(ans, data[iB])
            iB -= iB & -iB
        return ans

    data, numPow2 = makeBIT(N+1)
    setInit(list(range(N)))

    dp = [0] * (N+1)
    dp[-1] = 1
    for i in reversed(range(N)):
        X, D = XDs[i]
        j = bisect_left(Xs, X+D) - 1
        pos = getMax(j)
        setValue(i, pos)
        dp[i] = dp[pos+1] + dp[i+1]
        dp[i] %= MOD

    print(dp[0])


solve()


### FIXED CODE ###

from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline

def solve():
    MOD = 998244353
    INF = float('inf')

    N = int(input())
    XDs = [tuple(map(int, input().split())) for _ in range(N)] + [(10**12, 0)]

    XDs.sort()
    Xs = [X for X, D in XDs]

    def max2(x, y): return x if x >= y else y
    def makeBIT(numEle):
        numPow2 = 2 ** (numEle-1).bit_length()
        data = [-INF] * (numPow2+1)
        return data, numPow2
    def setInit(As):
        for iB, A in enumerate(As, 1):
            data[iB] = A
        for iB in range(1, numPow2):
            i = iB + (iB & -iB)
            data[i] = max2(data[i], data[iB])
    def setValue(iA, A):
        iB = iA + 1
        while iB <= numPow2:
            data[iB] = max2(data[iB], A)
            iB += iB & -iB
    def getMax(iA):
        iB = iA + 1
        ans = -INF
        while iB > 0:
            ans = max2(ans, data[iB])
            iB -= iB & -iB
        return ans

    data, numPow2 = makeBIT(N+1)
    setInit(list(range(N)))

    dp = [0] * (N+1)
    dp[-1] = 1
    for i in reversed(range(N)):
        X, D = XDs[i]
        j = bisect_left(Xs, X+D) - 1
        pos = getMax(j)
        setValue(i, pos)
        dp[i] = dp[pos+1] + dp[i+1]
        dp[i] %= MOD

    print(dp[0])


solve()
### BUGGY CODE ###

from math import factorial as fact
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
num = []

for i in range(2, int(M**0.5)+2):
    cnt = 0
    while M % i == 0:
        cnt += 1
        M //= i
    if cnt > 0:
        num.append(cnt)
    if M == 1:
        break
else:
    num.append(1)

ans = 1
for i in num:
    ans = (ans * fact(N-1+i)//(fact(i)*fact(N-1))) % (10**9+7)
print(ans)

### FIXED CODE ###

from math import factorial as fact
from operator import mul
from functools import reduce
import sys
input = sys.stdin.readline


def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


N, M = map(int, input().split())
num = []
p_flag = [True]*(int(M**0.5)+2)

for i in range(2, int(M**0.5)+2):
    if p_flag:
        for j in range(2*i, int(M**0.5)+2, i):
            p_flag[j] = False

        cnt = 0
        while M % i == 0:
            cnt += 1
            M //= i
        if cnt > 0:
            num.append(cnt)
        if M == 1:
            break
else:
    num.append(1)

ans = 1
for i in num:
    ans = (ans * cmb(N-1+i, i)) % (10**9+7)
print(ans)
### BUGGY CODE ###

S = input()
ans = 0
listmod = [0]*2019
for i in range(1,len(S)+1):
    T = int(S[-i:])
    modT = T%2019
    listmod[modT] += 1
for i in range(2019):
    if(i == 0):
        ans += listmod[0]
    else:
        if(listmod[i] > 1):
            ans += listmod[i] - 1
print(ans)

### FIXED CODE ###

S = input()
ans = 0
nd = 1
mod1 = 0
listmod = [0]*2019
for i in S[::-1]:
    mod1 = (int(i)*nd + mod1)%2019
    listmod[mod1] += 1
    nd = (nd*10)%2019
for i in range(2019):
    n = listmod[i]
    if(i == 0):
        if(n == 1):
            ans += 1
        elif(n >= 2):
            ans += ((n+1)*n)//2
    else:
        if(n > 1):
            ans += ((n-1)*n)//2
print(ans)
### BUGGY CODE ###

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

if n >= b-1:
  print(a*(b-1)//b - a*((b-1)//b))
else:
  ans = 0
  for x in range(1,n+1):
    ans = max(ans, int(a*x/b) - a*int(x/b))
  print(ans)

### FIXED CODE ###

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

x = min(b-1, n)
print(a*x//b -a*(x//b))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
N, M = map(int, input().split())
arys = []
for i in range(N):
    tmp = input()
    ary = [int(a) - 1 for a in tmp.split()]
    arys.append(ary)


s = set([i for i in range(M)])
min_num = None
while len(s) > 0:
    dic = {}
    for ary in arys:
        del_i = None
        for i, a in enumerate(ary):
            if a in s:
                if a not in dic:
                    dic[a] = 1
                else:
                    dic[a] += 1
                break
            del_i = i
        if del_i is not None:
            ary = ary[del_i + 1:]
    max_v = None
    max_k = None
    for k, v in dic.items():
        if max_v is None or max_v < v:
            max_v = v
            max_k = k
    if min_num is None or min_num > max_v:
        min_num = max_v
    s.remove(max_k)
print(min_num)


### FIXED CODE ###

# -*- coding: utf-8 -*-
N, M = map(int, input().split())
arys = []
for i in range(N):
    tmp = input()
    ary = [int(a) - 1 for a in tmp.split()]
    arys.append(ary)


s = set([i for i in range(M)])
i_s = [0 for i in range(len(arys))]
min_num = None
while len(s) > 0:
    select_num = [0 for i in range(M)]
    max_v = None
    max_k = None
    for j, ary in enumerate(arys):
        while ary[i_s[j]] not in s:
            i_s[j] += 1
        select_num[ary[i_s[j]]] += 1
        tmp = select_num[ary[i_s[j]]]
        if max_v is None or max_v < tmp:
            max_v = tmp
            max_k = ary[i_s[j]]
    if min_num is None or min_num > max_v:
        min_num = max_v
    s.remove(max_k)
print(min_num)
### BUGGY CODE ###

# coding: utf-8
# Your code here!
import itertools

N,C=[int(i) for i in input().split()]
D=[[int(i) for i in input().split()] for _ in range(C)]
c=[[int(i)-1 for i in input().split()] for _ in range(N)]

costXY = [[0]*C for _ in range(3)]



for X in range(3):
    for Y in range(C):
        costXY[X][Y] = sum([D[c[i][j]][Y] for i,j in itertools.product(range(N), repeat=2) if (i+j)%3==X])

#print(costXY)    

ans = 1<<31
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i==j or j==k or k==i:
                continue
            p=costXY[0][i] + costXY[1][j] + costXY[2][k]
#            print(p)
            ans = min(ans,p)
print(ans)
            
            
            
            
            


### FIXED CODE ###

# coding: utf-8
# Your code here!
import itertools

N,C=[int(i) for i in input().split()]
D=[[int(i) for i in input().split()] for _ in range(C)]
c=[[int(i)-1 for i in input().split()] for _ in range(N)]

costXY = [[0]*C for _ in range(3)]



for X in range(3):
    for Y in range(C):
        costXY[X][Y] = sum([D[c[i][j]][Y] for i,j in itertools.product(range(N), repeat=2) if (i+j)%3==X])

#print(costXY)    

ans = 1<<31
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i==j or j==k or k==i:
                continue
            p=costXY[0][i] + costXY[1][j] + costXY[2][k]
#            print(p)
            ans = min(ans,p)
print(ans)
### BUGGY CODE ###

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

flag = False
for count in range(1000000000):
    if abs(A-count) == abs(B-count):
        print(count)
        flag = True
        break
if flag == False:
    print("IMPOSSIBLE")

### FIXED CODE ###

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

if (A+B) % 2 ==1:
    print("IMPOSSIBLE")
else:
    print(int((A+B)/2))
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
B = 1
for i in range(N):
    B = B * A[i]
if B <= 10 ** 18:
    print(B)
else:
    print(-1)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
 
 
ans = 1
if 0 in a:
    print(0)
    exit()
 
for i in a:
    ans *= i
    if ans > 10**18:
        print(-1)
        exit()
 
print(ans)
### BUGGY CODE ###

import numpy as np
n, x, y = map(int, input().split())

ans = np.zeros(n+1,dtype=np.uint32)
for i in range(1,n):
    for j in range(i+1,n+1):
        ans[min(j-i,abs(x-i)+1+abs(y-j),abs(y-i)+1+abs(x-j))] += 1

for i in range(1,n):
    print(ans[i])

### FIXED CODE ###

import numpy as np
n, x, y = map(int, input().split())

ans = [0] * n
for i in range(1,n):
    for j in range(i+1,n+1):
        ans[min(j-i,abs(x-i)+1+abs(y-j),abs(y-i)+1+abs(x-j))] += 1

for i in range(1,n):
    print(ans[i])
### BUGGY CODE ###

n,q = map(int,input().split())
s = input()
for i in range(q):
    x,y = map(int,input().split())
    print(s[x-1:y].count("AC"))

### FIXED CODE ###

n,q = map(int,input().split())
s = list(input())
a = [0]*n
c = 0
for i in range(1,n):
    if s[i-1]=="A" and s[i]=="C":
        c+=1
    a[i]=c
for i in range(q):
    l,r = map(int,input().split())
    print(a[r-1]-a[l-1])
### BUGGY CODE ###

N = int(input())
 
for n in range(1,N+1):
    cnt = 0
    for i in range(1,100):
        for j in range(1,100):
            for k in range(1,100):
                a = i**2 + j**2 + k**2 + i*j + j*k + k*i
                if a == n:
                    cnt += 1
    
    print(cnt)

### FIXED CODE ###

N = int(input())

anslist = [0] * N

for i in range(1,int(N**0.5)+1):
    for j in range(1,int(N**0.5)+1):
        for k in range(1,int(N**0.5)+1):
            a = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if a <= N:
                anslist[a-1] += 1
    

for i in range(N):
    print(anslist[i])
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
s=set()
for i in range(N-1):
    if A[i] not in s:
        print(A.count(i+1))
    else:
        print(0)
print(0)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
P=[0]*N
for i in range(N-1):
    P[A[i]-1]+=1
for i in range(N):
    print(P[i])