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

# 初期入力
N = int(input())
AB = [list(map(int, input().split())) for i in range(N-1)]

#　頂点をキー、つながり先をVALUEの辞書
tunagari = {}
for ab in AB:
    tunagari.setdefault(ab[0], []).append(ab[1])
    tunagari.setdefault(ab[1], []).append(ab[0])
color_count = [len(i) for i in tunagari.values() ]
color_max =max(color_count)     
color_list =[i for i in range(1,color_max+1)]
#頂点とつながり先をキー、色をValueの辞書
color_hen = {}

"""
for i in AB:
    color_hen[AB[0]] =1
"""
from collections import defaultdict

color_moto ={i:color_list for i in tunagari.keys()} 
color_ten_ten = {}
col =[] #　色の一時的な変数
for k,v in tunagari.items():
    color =[]
    color.extend(color_moto[k])
    for ii in v:
        #print(color,end=" ")
        if (k,ii) not in color_ten_ten.keys():
            xx = color.pop() # ポップだから速度のため末尾から消す  
            #print(xx,end="  ")
            color_ten_ten.setdefault((k,ii) ,xx)  
            color_ten_ten.setdefault((ii,k) ,xx)
        # 辞書から取り出す→消す→辞書に戻す(後の検索先)        
            col.extend(color_moto[ii]) 
            col.remove(xx)
            #print(col)
            color_moto[ii] = col
            col=[]
     
print(color_max) #答え　最小の色数（根の辺の数）
#AB＝color_ten_tenのキーが同じなら、値の色をprint
for i in AB:
    ab = tuple(i)
    if ab in color_ten_ten.keys():
        print(color_ten_ten[ab])



### FIXED CODE ###

"""
参考    yy4さん 2019-11-24 21:24:43
516 ms          PyPy3 (2.4.0)
"""
#def solve():
from collections import deque
import sys

input = sys.stdin.readline

n = int(input())

g = tuple(set() for _ in range(n))
for idx in range(n - 1):
    a, b = (int(x) - 1 for x in input().split())
    g[a].add((b, idx))
    g[b].add((a, idx))

q = deque()
q.append((0, -1, -1))

e = [-1] * n  # e[-1]は使わない
used = [False] * n
used[0] = True
while q:
    v, v_idx, prev_color = q.popleft()
    curr = 1 if prev_color != 1 else 2
    for u, u_idx in g[v]:
        if used[u]:
            continue
        used[u] = True
        e[u_idx] = curr
        q.append((u, u_idx, curr))
        curr += 1
        if curr == prev_color:
            curr += 1

ret = e[:-1]
#return len(set(ret)), ret

    
#l, ret = solve()
l=len(set(ret))
print(l)
print(*ret, sep='\n')
### BUGGY CODE ###

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

# L, R, U, D方向の照らされるマス数を事前に計算
L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]

for i in range(H):
  for j in range(W):
    road = S[i][::-1][W - j - 1:]
    cnt = 0
    for k in road:
      if k == ".":
        cnt += 1
      else:
        break
    L[i][j] = cnt
    
    road = S[i][j:]
    cnt = 0
    for k in road:
      if k == ".":
        cnt += 1
      else:
        break
    R[i][j] = cnt

# 転置行列を準備
ST = list(map(list, zip(*S)))

for i in range(W):
  for j in range(H):
    road = ST[i][::-1][H - j - 1:]
    cnt = 0
    for k in road:
      if k == ".":
        cnt += 1
      else:
        break
    U[j][i] = cnt

    road = ST[i][j:]
    cnt = 0
    for k in road:
      if k == ".":
        cnt += 1
      else:
        break
    D[j][i] = cnt

ans = 0
for i in range(H):
  for j in range(W):
    ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)

print(ans)


### FIXED CODE ###

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

# L, R, U, D方向の照らされるマス数を事前に計算
L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]

for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      L[i][j] = 0
    elif j == 0:
      L[i][j] = 1
    else:
      L[i][j] = L[i][j - 1] + 1

for i in range(H):
  for j in reversed(range(W)):
    if S[i][j] == "#":
      R[i][j] = 0
    elif j == W - 1:
      R[i][j] = 1
    else:
      R[i][j] = R[i][j + 1] + 1

for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      U[i][j] = 0
    elif i == 0:
      U[i][j] = 1
    else:
      U[i][j] = U[i - 1][j] + 1

for i in reversed(range(H)):
  for j in range(W):
    if S[i][j] == "#":
      D[i][j] = 0
    elif i == H - 1:
      D[i][j] = 1
    else:
      D[i][j] = D[i + 1][j] + 1

ans = 0
for i in range(H):
  for j in range(W):
    ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)

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

INT_MAX=10**11+7
MOD=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
#=======================================================================
# Python 3 implementation of the approach

# Function to return the count of sub-strings
# of str that are divisible by k
def countSubStr(str, l, k):
	count = 0

	for i in range(l):
		n = 0

		# Take all sub-strings starting from i
		for j in range(i, l, 1):
			n = n * 10 + (ord(str[j]) - ord('0'))

			# If current sub-string is divisible by k
			if (n % k == 0):
				count += 1

	# Return the required count
	return count

# Driver code
if __name__ == '__main__':
	str = input()
	l = len(str)
	k = 2019
	print(countSubStr(str, l, k))

# This code is contributed by
# Sanjit_Prasad


### FIXED CODE ###

INT_MAX=10**11+7
MOD=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
#=======================================================================
s=input()
digits=list(int(i) for i in s)
n=len(s)
powermod=[0]*2019
powermod[0]=1
pow10=1
num=0
ans=0
for digit in reversed(digits):
    num+=digit*pow10
    rem=num%2019
    ans+=powermod[rem]
    pow10*=10
    powermod[rem]+=1
    num=rem
    pow10%=2019
print(ans)
### BUGGY CODE ###

import numpy as np

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

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

  
dp=[[float('inf')]*(sum(value)+1) for i in range(n+1)]
dp[0][0]=0

for i in range(n):
  for j in range(sum(value)+1):
    dp[i+1][j]=min(dp[i+1][j],dp[i][j])                             #+1、個数制限なし
    dp[i+1][np.minimum(j+value[i],sum(value))]=np.minimum(dp[i+1][np.minimum(j+value[i],sum(value))],dp[i][j]+weight[i])

ans=0
for i in range(sum(value)+1):
  if dp[-1][i]<=w:
    ans=max(ans,i)

print(ans)

### FIXED CODE ###

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

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

xxx=sum(value)
dp=[[float('inf')]*(sum(value)+1) for i in range(n+1)]
dp[0][0]=0

for i in range(n):
  for j in range(xxx+1):
    dp[i+1][j]=min(dp[i+1][j],dp[i][j])                             #+1、個数制限なし
    dp[i+1][min(j+value[i],xxx)]=min(dp[i+1][min(j+value[i],xxx)],dp[i][j]+weight[i])

ans=0
for i in range(xxx+1):
  if dp[-1][i]<=w:
    ans=max(ans,i)

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

import bisect
A, B, Q = map(int,input().split())
 
S = [-10**18] + [int(input()) for _ in [0]*A] + [10**18]
T = [-10**18] + [int(input()) for _ in [0]*B] + [10**18]

for _ in range(Q):
    x = int(input())
    ans = 10**18
    for i in range(2):
        if i == 0:
            a = S
            b = T
        elif i== 1:
            a = T
            b = S
 
        idx_x = bisect.bisect_left(a,x)
        for j in range(2):
            ax = a[idx_x-j]
            idx_a = bisect.bisect_left(b,ax)
            for k in range(2):
                bx = b[idx_a-k]
                ans = min(ans, abs(ax-x)+abs(bx-ax))
    print(ans)

### FIXED CODE ###

import bisect
import sys

A, B, Q = map(int,input().split())
s = [-(10**18)] + list(map(int, (sys.stdin.readline() for _ in [0]*A))) + [10**18]
t = [-(10**18)] + list(map(int, (sys.stdin.readline() for _ in [0]*B))) + [10**18]


def solve(s,t,x):
    ans = 10**18
    for i in range(2):
        a, b = (s, t) if i==0 else (t, s)
        posX1 = bisect.bisect_left(a,x)
        for j in range(2):
            ax = a[posX1 -j]
            posX2 = bisect.bisect_left(b,ax)
            for k in range(2):
                bx = b[posX2-k]
                ans = min(ans, abs(x-ax)+abs(bx-ax))
    return ans

for _ in range(Q):
    x = int(input())
    print(solve(s,t,x))
### BUGGY CODE ###

N = int(input())
n = 0
for m in range(N - 1, 0, -1):
    n = n + m
print(n)


### FIXED CODE ###

N = int(input())
print((N * (N - 1)) // 2)
### BUGGY CODE ###

m = 10**9+7

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

l = [0 for i in range(n)]
ll = [[]for i in range(n)]

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

if n==1:
    print(k)
    exit()
if k<3:
    if n==1:
        print(k)
        exit()
    elif n==2:
        print(k*(k-1))
        exit()
    else:
        print(0)
        exit()

q = max(l)
if k<q+1:
    print(0)
    exit()

f = [1,1]
for i in range(2,k+1):
    f.append(f[-1]*i%m)

g = [1]
for i in range(k):
    g.append(pow(f[i+1],m-2,m))


ans = k

ans *= f[k-1]*g[k-1-l[0]]%m

visited = [0]*n
visited[0]==1
for x in ll[0]:
    visited[x]==1

for i in range(1,n):
    if visited[i] ==0:
        ans *= f[k-2]*g[k-1-l[i]]%m
        for x in ll[i]:
            visited[x]==1

print(ans%m)



### FIXED CODE ###

m = 10**9+7

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

l = [0 for i in range(n)]
ll = [[]for i in range(n)]

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

if n==1:
    print(k)
    exit()

q = max(l)
if k<q+1:
    print(0)
    exit()

f = [1,1]
for i in range(2,k+1):
    f.append(f[-1]*i%m)

g = [1]
for i in range(k):
    g.append(pow(f[i+1],m-2,m))


ans = k

ans *= f[k-1]*g[k-1-l[0]]
ans %= m

visited = [0]*n
visited[0]==1
for x in ll[0]:
    visited[x]==1

for i in range(1,n):
    if visited[i] ==0:
        ans *= f[k-2]*g[k-1-l[i]]
        ans %= m
        for x in ll[i]:
            visited[x]==1

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

X = int(input())

# for b in range(65, -64, -1):
for b in range(1000000, -1000000, -1):
    a = (X + b**5)**0.2
    # print('b a', b, a)
    if type(a) == complex:
        if a.imag != 0:
            continue
        print(int(a.real), b)
        exit()
    elif a.is_integer():
        print(int(a), b)
        exit()

for a in range(1000000, -1000000, -1):
    b = (X - a**5)**0.2
    # print('b a', b, a)
    if type(b) == complex:
        if b.imag != 0:
            continue
        print(int(b.real), a)
        exit()
    elif b.is_integer():
        print(int(a), b)
        exit()


### FIXED CODE ###

X = int(input())

for a in range(-1000, 1000):
    for b in range(-1000, 1000):
        if a**5 - b**5 == X:
            print(a, b)
            exit()
### BUGGY CODE ###

# 解説
# https://img.atcoder.jp/agc018/editorial.pdf

def solve():
    import sys

    sys.setrecursionlimit(10 ** 7)

    def simulate(use: set):
        if not use:
            return n
        cnt = [0] * m
        for player in a:
            for sport in player:
                if sport in use:
                    cnt[sport] += 1
                    break
        max_ = max(cnt)
        ret = max_
        for j, c in enumerate(cnt):
            if c == max_:
                ret = min(ret, simulate(use - {j}))
        return ret

    n, m = map(int, input().split())
    a = [tuple(int(x) - 1 for x in input().split()) for _ in range(n)]
    use = set(range(m))
    return simulate(use)


print(solve())

# まず、すべてのスポーツを実施すると仮定して、どのスポーツに何人の人が参加するか調べます。
# ここで、最も参加人数の多いスポーツがスポーツ P で、その参加人数が Q 人だとします。
# 当り前ですが、この段階で、参加人数の最大値が Q の解が得られています。
# よって、あと考えるべきは、参加人数の最大値が Q 未満の解です。
# そして、そのような解において、スポーツ P は必ず実施されません。
# なので、Q 未満の解を求めるには、スポーツ P を候補から外した上で、
# もう一度同じ問題を解きなおせばよいです。
# これを再帰的に行っていけば、最終的な解を求めることができます。
# 再帰するごとに候補の数が減るので、再帰は合計 M 回呼ばれます。
# 誰がどのスポーツを選ぶのか愚直にシミュレーションすると O(NM) かかるので、
# 全体で O(NM2) でこの問題は解けました。
# なお、シミュレーションを工夫すると、全体で O(NM) でこの問題を解くこともできます。


### FIXED CODE ###

# https://atcoder.jp/contests/agc018/submissions/2152627
# 写経

from collections import deque
from operator import itemgetter


def solve(n, m, prefers):
    def sub(prefers, canceled):
        ret = [0] * m
        for pref in prefers:
            while canceled[pref[0]]:
                pref.popleft()
            ret[pref[0]] += 1
        return max(enumerate(ret), key=itemgetter(1))

    canceled = [False] * m
    ret = n
    for _ in range(m):
        s, c = sub(prefers, canceled)
        canceled[s] = True
        ret = min(ret, c)
    return ret


if __name__ == '__main__':
    n, m = map(int, input().split())
    prefers = [deque(int(x) - 1 for x in input().split()) for _ in range(n)]
    print(solve(n, m, prefers))
### BUGGY CODE ###

L = [int(input()) for _ in range(int(input()))]
r = 0
for s in set(L):
    C = L.count(s)
    if C == 1:
        r+=1
    else:
        if L.count(s) % 2 != 0:
            r+=1
print(r)

### FIXED CODE ###

S = set()
for _ in range(int(input())):
    A = int(input())
    if A not in S:
        S.add(A)
    else:
        S.remove(A)
print(len(S))
### BUGGY CODE ###

import numpy as np
import collections
import math

s = input()[::-1]
length = len(s)
a = np.zeros(length)
d = np.zeros(length)

for i in range(length):
    a[i] = int(s[i]) * pow(10, i) % 2019
d[0] = a[0]

for i in range(length-1):
    d[i+1] = (d[i] + a[i+1]) % 2019
    
x = np.array([i for i in collections.Counter(d).values()])
x = x[np.where(x > 1)]

print(int(sum([math.factorial(x[i]) for i in range(x.shape[0])]) / 2) + d.shape[0] - np.count_nonzero(d))

### FIXED CODE ###

import numpy as np

s = input()[::-1]
length = len(s)
a = np.zeros(length, dtype=int)
d = np.zeros(length, dtype=int)
ans = np.zeros(2019, dtype=int)
x = 10

a[0] = int(s[0])
d[0] = a[0]
ans[d[0]] += 1

for i in range(1, length):
    a[i] = int(s[i]) * x % 2019
    d[i] = (d[i-1] + a[i]) % 2019
    ans[d[i]] += 1
    x = x * 10 % 2019

ans_c = ans[np.nonzero(ans)]

print(int(sum([ans_c[i] * (ans_c[i]-1) for i in range(ans_c.shape[0])]) / 2) + ans[0])
### BUGGY CODE ###

from collections import deque

H,W = map(int,input().split())

N = H*W

data = ["#" * (W+2)]
for i in range(H):
  data.append("#"+input()+"#")
data.append("#" * (W+2))

offsets = [(0,1),(0,-1),(1,0),(-1,0),]

tree = {}
for i in range(1,H+1):
  for j in range(1,W+1):
    if data[i][j] != ".":
      pass
    else:
      tree[(i,j)] = []
      for o in offsets:
        i_ = i+o[0]
        j_ = j+o[1]
        if data[i_][j_] == "." :
          tree[(i,j)].append((i_,j_))

nodes = list(tree.keys())
  
FARTHEST = 0

for start_node in nodes:
  flag = set()
  # キューを作成して初期ノード(root)を入れる
  q = deque()
  q.append((start_node,0))
  farthest = None

  # キューが空になるまで繰り返す
  while len(q) > 0:
      # キューの先頭（左端）からnodeを取り出す
      data = q.popleft()
      node = data[0]
      distance = data[1]
      if node is not None:
          farthest = (node,distance)
          flag.add(node)
          childs = tree[node]
          for child in childs:
            if child not in flag:
              q.append((child,distance+1))

      if FARTHEST < farthest[1]:
        FARTHEST = farthest[1]

print(FARTHEST)

### FIXED CODE ###

from collections import deque

INF = float("inf")

H,W = map(int,input().split())

N = H*W

data = ["#" * (W+2)]
for i in range(H):
  data.append("#"+input()+"#")
data.append("#" * (W+2))

offsets = [(0,1),(0,-1),(1,0),(-1,0),]

nodes = []
for i in range(1,H+1):
  for j in range(1,W+1):
    if data[i][j] == ".":
      nodes.append((i,j))

FARTHEST = 0

for start_node in nodes:
  i = start_node[0]
  j = start_node[1]
  d = [[INF]*(W+2) for i in range(H+2)]
  d[i][j] = 0
  q = deque([(i,j)])
  res = 0
  while q:
    x,y = q.popleft()
    nd = d[x][y]+1
    for o in offsets:
      nx, ny = x+o[0], y+o[1]
      if data[nx][ny] == "#":
        continue
      if nd < d[nx][ny]:
        d[nx][ny] = nd
        q.append((nx,ny))
        res = nd
  if res > FARTHEST:
    FARTHEST = res

print(FARTHEST)
### BUGGY CODE ###

n = int(input())
*A, = map(int, input().split())
a, b, c = A.count(1), A.count(2), A.count(3)
DP = [[[0 for k in range(n+1)] for j in range(n+1)] for i in range(n+1)]
for k in range(c+1):
    for j in range(b+c-k+1):
        for i in range(n-j-k+1):
            if i+j+k == 0:
                continue
            tmp = n
            if i > 0:
                tmp += DP[i-1][j][k]*i
            if j > 0:
                tmp += DP[i+1][j-1][k]*j
            if k > 0:
                tmp += DP[i][j+1][k-1]*k
            DP[i][j][k] = tmp/(i+j+k)
print(DP[a][b][c])


### FIXED CODE ###

n = int(input())
*A, = map(int, input().split())
a, b, c = A.count(1), A.count(2), A.count(3)
DP = [[[0.0 for k in range(n+1)] for j in range(n+1)] for i in range(n+1)]
for k in range(c+1):
    for j in range(b+c-k+1):
        for i in range(n-j-k+1):
            if i+j+k == 0:
                continue
            tmp = n
            if i > 0:
                tmp += DP[i-1][j][k]*i
            if j > 0:
                tmp += DP[i+1][j-1][k]*j
            if k > 0:
                tmp += DP[i][j+1][k-1]*k
            DP[i][j][k] = tmp/(i+j+k)
print(DP[a][b][c])
### BUGGY CODE ###

n, m, k = map(int, input().split())
a =  list(map(int, input().split()))
b = list(map(int, input().split()))
a_sum, b_sum = [0], [0]
for i in range(n):
  a_sum.append(a_sum[i]+a[i])
for i in range(m):
  b_sum.append(b_sum[i]+b[i])
ans, j = 0, m
for i in range(n+1):
  if a_sum[i] > k:
    break
  while b_sum[j] > k - a_sum[i]:
    j =- 1
  ans = max(ans, i+j)
print(ans)

### FIXED CODE ###

n, m, k = map(int, input().split())
a =  list(map(int, input().split()))
b = list(map(int, input().split()))
a_sum, b_sum = [0], [0]
for i in range(n):
  a_sum.append(a_sum[i]+a[i])
for i in range(m):
  b_sum.append(b_sum[i]+b[i])
ans, j = 0, m
for i in range(n+1):
  if a_sum[i] > k:
    break
  while b_sum[j] > k - a_sum[i]:
    j -= 1
  ans = max(ans, i+j)
print(ans)
### BUGGY CODE ###

import sys
from collections import defaultdict
input = sys.stdin.readline

H, W = map(int, input().split())

A = [tuple(map(int, input().split())) for _ in range(H)]
B = [tuple(map(int, input().split())) for _ in range(H)]
dp = [[defaultdict(lambda : False) for _ in range(W)] for _ in range(H)]
dp[0][0][0] = True

for h in range(H):
    for w in range(W):
        C = A[h][w] - B[h][w]
        for v, f in dp[h][w].items():
            if f:
                if h < H - 1:
                    dp[h + 1][w][v + C] = True
                    dp[h + 1][w][v - C] = True
                if w < W - 1:
                    dp[h][w + 1][v + C] = True
                    dp[h][w + 1][v - C] = True

ans = 10**10
C = A[H - 1][W - 1] - B[H - 1][W - 1]
for v, f in dp[H - 1][W - 1].items():
    if f:
        ans = min(ans, abs(v - C))
        ans = min(ans, abs(v + C))
print(ans)

### FIXED CODE ###

H, W = map(int, input().split())
M = (H + W) * 80

A = [tuple(map(int, input().split())) for _ in range(H)]
B = [tuple(map(int, input().split())) for _ in range(H)]

dp = [[0] * W for _ in range(H)]
dp[0][0] = (1 << (M - abs(A[0][0] - B[0][0])))

for h in range(H):
    for w, (a, b) in enumerate(zip(A[h], B[h])):
        d = abs(a - b)
        mask = 0
        if h > 0:
            mask |= (dp[h - 1][w] << d)
            mask |= (dp[h - 1][w] >> d)
        if w > 0:
            mask |= (dp[h][w - 1] << d)
            mask |= (dp[h][w - 1] >> d)
        dp[h][w] |= mask

state = dp[-1][-1]
nums = []
for digit, b in enumerate(bin(state)[2:][:: -1]):
    if b == '1':
        nums.append(digit - M)
ans = min(abs(n) for n in nums)
print(ans)
### BUGGY CODE ###

def resolve():
    A, B, K = map(int, input().split())
    count = [A]
    ans = []
    for _ in range(1, B-A+1):
        count.append(A+_)
    if K > B-A-1:
        K = B-A+1
    for i in range(K):
        ans.append(count[i])
        if count[(i+1)*-1] >= A+K-1:
            ans.append(count[(i+1)*-1])
    an = sorted(set(ans))
    for i in range(len(an)):
        print(an[i])
resolve()

### FIXED CODE ###

def resolve():
    A, B, K = map(int, input().split())
    if 2*K > B-A+1:
        for _ in range(B-A+1):
            print(A+_)
    else:
        for i in range(K):
            print(A+i)
        for j in range(K):
            print(B-K+j+1)
resolve()
### BUGGY CODE ###

N = int(input())
S = []
for i in range(N):
  S.append(input())

cnt = 0
for i in range(N):
  for j in range(i + 1, N):
#    print (i, j, end=" ")
    a = sorted(list(S[i]))
    b = sorted(list(S[j]))
#    print (a, b)
    
    for k in range(10):
      if a[k] != b[k]:
        break
    else:
      cnt += 1
    
print (cnt)

### FIXED CODE ###

import math

N = int(input())
S = []
for i in range(N):
  S.append(''.join(sorted(input())))

from collections import Counter
Sc = Counter(S)

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

cnt = 0
for i in Sc.values():
  if i >= 2:
    cnt += com(i,2)
  
print (cnt)
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
B=sorted(A)
ans=[]
for i in range(N):
  mnum=A.index(B[i])
  ans.append(mnum+1)
for i in ans:
  print(i,end=" ")

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
Alist=[]
for i in range(N):
  Alist.append((A[i],i+1))
Alist=sorted(Alist,key=lambda x: x[0])
for i in range(N):
  print(Alist[i][1],end=" ")
### BUGGY CODE ###

max = 1-10**9
i = 0
j = 0
n_max = 0

n_max = int(raw_input())
price = [0]*n_max
for i in range(n_max):
    price[i] = int(raw_input())
for i in range(n_max):
    for j in range(i+1, n_max):
        if max <= (price[j] - price[i]):
            max = price[j] - price[i]
print max

### FIXED CODE ###

import sys

n = int(raw_input())

min_R = int(raw_input())
nums = map(int, sys.stdin.readlines())

ans = -10**9

for num in nums:
    if num - min_R > ans:
        ans = num - min_R
    if num < min_R:
        min_R = num
        
print ans
### BUGGY CODE ###

import sys
from collections import defaultdict

input = sys.stdin.readline


class AtCoder:
    def main(self):
        H, W = map(int, input().split())

        blacks = []
        field = defaultdict(lambda: '#')
        for h in range(H):
            for w, c in enumerate(input().rstrip()):
                field[(h + 1, w + 1)] = c
                if c == '#':
                    blacks.append((h + 1, w + 1))

        moving_range = ((1, 0), (-1, 0), (0, -1), (0, 1))

        ans = 0
        while blacks:
            next_blacks = []
            for b_h, b_w in blacks:
                for m_h, m_w in moving_range:
                    target = (b_h + m_h, b_w + m_w)
                    if field[target] == '.':
                        field[target] = '#'
                        next_blacks.append(target)
            if len(next_blacks) > 0:
                ans += 1
            blacks = next_blacks

        print(ans)


# Run main
if __name__ == '__main__':
    AtCoder().main()


### FIXED CODE ###

import sys
from collections import defaultdict

input = sys.stdin.readline


class AtCoder:
    def main(self):
        H, W = map(int, input().split())
        A = [list(input().rstrip()) for _ in range(H)]

        blacks = []
        for h in range(H):
            for w in range(W):
                if A[h][w] == '#':
                    blacks.append((h + 1, w + 1))

        moving_range = ((1, 0), (-1, 0), (0, -1), (0, 1))

        ans = 0
        while blacks:
            next_blacks = []
            for b_h, b_w in blacks:
                for m_h, m_w in moving_range:
                    h, w = b_h + m_h, b_w + m_w
                    if not (0 < h <= H and 0 < w <= W):
                        continue
                    if A[h-1][w-1] == '.':
                        A[h-1][w-1] = '#'
                        next_blacks.append((h, w))
            if len(next_blacks) > 0:
                ans += 1
            blacks = next_blacks

        print(ans)


# Run main
if __name__ == '__main__':
    AtCoder().main()
### BUGGY CODE ###

from sys import stdin
input = stdin.readline

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

ans = 1

for a in A:
    ans *= a

if ans > pow(10, 18):
    print(-1)
else:
    print(ans)


### FIXED CODE ###

from sys import stdin
input = stdin.readline

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

ans = 1

if 0 in A:
    print(0)
    exit()

for a in A:
    ans *= a
    if a > pow(10, 18) or ans > pow(10, 18):
        print(-1)
        exit()


print(ans)