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

N = int(input())
uvw = []
for _ in range(N-1):
    uvw.append(tuple(map(int, input().split())))

G=[[0]*(N+1) for _ in range(N+1)]
for el in uvw:
    G[el[0]][el[1]]=el[2]
    G[el[1]][el[0]] = el[2]
#print(G)

H=[[] for _ in range(N+1)]
for el in uvw:
    H[el[0]].append(el[1])
    H[el[1]].append(el[0])
#print(H)

seen=[False]*(N+1)
distance=[0]*(N+1)
def dfs(n):
    seen[n]=True
    for nxt in H[n]:
        if seen[nxt] == False:
            distance[nxt] = distance[n] + G[n][nxt]
            dfs(nxt)

dfs(1)
#print(distance)
#print(seen)

for val in distance[1:]:
    if val % 2 == 0:
        print(0)
    else:
        print(1)




### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

N = int(input())
uvw = []
for _ in range(N-1):
    uvw.append(tuple(map(int, input().split())))


H=[[] for _ in range(N+1)]
for el in uvw:
    H[el[0]].append((el[1], el[2]))
    H[el[1]].append((el[0], el[2]))
#print(H)

seen=[False]*(N+1)
color=[0]*(N+1)
def dfs(n):
    seen[n]=True
    for nxt in H[n]:
        if seen[nxt[0]] == False:
            if nxt[1] % 2 == 0:
                color[nxt[0]]=color[n]
            else:
                color[nxt[0]]=color[n] ^ 1
            dfs(nxt[0])

dfs(1)
#print(distance)
#print(seen)

for i in range(1,N+1):
    print(color[i])
### BUGGY CODE ###

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

lists = [[] for _ in range(N)]
items = [list(map(int, input().split())) for _ in range(M)]
for p, y in items:
  lists[p-1].append(y)

for n in range(N):
  lists[n].sort()  

for p, y in items:
  index = lists[p-1].index(y)
  f = lambda x: ('0' * (6 - len(str(x))) +  str(x))
  print(f(p) + f(index+1))

### FIXED CODE ###

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

lists = [[] for _ in range(N)]
items = [list(map(int, input().split())) for _ in range(M)]
for p, y in items:
  lists[p-1].append(y)

dic = {}

for n in range(N):
  lists[n].sort()  

for n in range(N):
  l = lists[n]
  count = 1
  for i in l:
    dic[i] = count
    count+=1

for p, y in items:
  print("{:06g}{:06g}".format(p,dic[y]))
### BUGGY CODE ###

if __name__ == "__main__":

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

    a = [[] for j in range(h)]
    for i in range(h): a[i] = input()

    reached = [[True for i in range(w+2)] for j in range(h+2)]
    for i in range(1, h+1): reached[i][1:-1] = [False for i in range(w)]

    queue = []
    for i in range(h):
        for j in range(w):
            if a[i][j] == "#":
                queue.append([i+1, j+1])
                reached[i+1][j+1] = True

    res = 0
    head = 0
    tail = len(queue)
    count = len(queue)
    i = 0
    while tail - head > 0:
        k = queue[0][0]
        l = queue[0][1]
        if not reached[k+1][l]:
            queue.append([k+1,l])
            reached[k+1][l] = True
            tail += 1
        if not reached[k][l+1]:
            queue.append([k,l+1])
            reached[k][l+1] = True
            tail += 1
        if not reached[k-1][l]:
            queue.append([k-1,l])
            reached[k-1][l] = True
            tail += 1
        if not reached[k][l-1]:
            queue.append([k,l-1])
            reached[k][l-1] = True
            tail += 1

        tail -= 1
        i += 1
        queue.pop(0)
        if i == count and tail - head > 0:
            count = tail
            i = 0
            res += 1
        else:
            pass

    print(res)

### FIXED CODE ###

def main():
  h,w = map(int,input().split())

  q = []
  reached = [[True]*(w+2)]
  for i in range(1, h+1):
    reached.append([True] + [s == '#' for s in list(input())] + [True])
    for j in range(1,w+1):
      if reached[i][j]: q.append((i,j))
  reached.append([True]*(w+2))

  res = 0
  for i in range(100000000):
    qq = []
    for k,l in q:
      if not reached[k+1][l]:
        qq.append((k+1, l))
        reached[k+1][l] = True
      if not reached[k][l+1]:
        qq.append((k, l+1))
        reached[k][l+1] = True
      if not reached[k-1][l]:
        qq.append((k-1, l))
        reached[k-1][l] = True
      if not reached[k][l-1]:
        qq.append((k, l-1))
        reached[k][l-1] = True
    if len(qq) == 0:
      break
    else:
      pass

    q = qq
    res += 1

  print(res)
  return 0

if __name__ == "__main__":
  main()
### BUGGY CODE ###

# -*- coding: utf-8 -*-
from heapq import heapify, heappop, heappush

N = int(input())
INF = float("inf")
d = {n: INF for n in range(N)}
d[0] = 0
adj = [[] for _ in range(N)]

searched = [False for _ in range(N)]
searched[0] = True

for n in range(N):
    inp = tuple(map(int, input().split()))
    assert n == inp[0]
    for i in range(inp[1]):
        adj[n] = list(zip(inp[2::2], inp[3::2]))

heap = [[0, 0]]

while len(heap):
    pcost, p = heappop(heap)
    searched[p] = True
    
    if d[p] < pcost:
        continue
    
    for v in adj[p]:
        if not searched[v[0]]:
            new_cost = pcost + v[1]
            if new_cost < d[v[0]]:
                d[v[0]] = new_cost
                heappush(heap, [d[v[0]], v[0]])

for n in range(N):
    print("{} {}".format(n, d[n]))

### FIXED CODE ###

# -*- coding: utf-8 -*-
from heapq import heappop, heappush
def inpl(): return list(map(int, input().split()))
INF = float("inf")
N = int(input())
G = []
for _ in range(N):
    I = inpl()
    G.append(zip(*[I[3::2], I[2::2]]))

def dijkstra(G):
    C = [INF]*(N)
    C[0] = 0
    visited = [False] * (N)
    Q = [[0, 0]]

    while Q:
        c, u = heappop(Q)
        if C[u] < c:
            continue
        visited[u] = True
        for d, v in G[u]:
            if visited[v]:
                continue
            e = c + d
            if e < C[v]:
                C[v] = e
                heappush(Q, [e, v])
    return C

for i, c in enumerate(dijkstra(G)):
    print(i, c)
### BUGGY CODE ###


S = input()

def comn(n,m):
    originamN = n
    s1 = 1
    s2 = 1
    while n >= (originamN-m + 1):
        s1 = s1 * n
        n = n - 1

    while m >= 1:
        s2 = s2 * m
        m = m - 1

    return s1 // s2


def calculate(s):
    length = len(s)

    dict = {0:1}
    for i in range(len(s)):
        index = (int(s[i:length]) % 2019)
        if dict.get(index) != None:
            dict.__setitem__(index, dict.get(index) + 1)
        else:
            dict.__setitem__(index, 1)

    result = 0
    for val in dict.values():
        if val > 1:
            result = result + val - 1

    print(result)
calculate(S)


### FIXED CODE ###

s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力
### BUGGY CODE ###

import numpy as np


def read_input(trans=int):
    return list(map(trans, input().split()))


N, K = read_input()
A = np.array(read_input(), dtype="int")
B = np.zeros(N, dtype="int")
coordinate = np.arange(1, N+1)

limit_count = np.log(N)
for j in range(K):
    for i in range(N):
        c = coordinate[i]
        B[i] = (A >= np.abs(coordinate - c)).sum()
    A = B.copy()
    if j > limit_count:
        break


print(" ".join(map(str, A.tolist())))


### FIXED CODE ###

def read_input(trans=int):
    return list(map(trans, input().split()))


N, K = read_input()
A = read_input()
K = min(K, 41)

for _ in range(K):
    B = [0]*N
    for i in range(N):
        start = max(i-A[i], 0)
        end = min(i+A[i], N-1)

        B[start] += 1
        if end+1 < N:
            B[end+1] -= 1
    for i in range(1, N):
        B[i] += B[i-1]
    A = B.copy()


print(" ".join(map(str, A)))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 9)
N,K=map(int,input().split())
S=input()

#N=14
#K=2
#S="11101010110011"

LIST=[[[0] for j in range (2)]for i in range(N)]

t=S[0]
c=0
k=0
for i in range(N):
    if(t!=S[i]):
        LIST[k][0]=c
        LIST[k][1]=t
        t=S[i]
        k+=1
        c=0
    c+=1

LIST[k][0]=c
LIST[k][1]=t
LIST=LIST[0:k+1]
MAX=0

def calc(i,s,K,f):
    global MAX
    MAX=max(MAX,s)
    if(i==len(LIST)):
        return

    if(LIST[i][1]=="1"):
        s+=LIST[i][0]
        MAX=max(MAX,s)
        i+=1
        if(i==len(LIST)):
            return
    if(K==0):
        return
    if(K>=1):
        calc(i+1,s+LIST[i][0],K-1,1)
    if(f==0):
        calc(i+1,0,K,0)

calc(0,0,K,0)
print(MAX)


### FIXED CODE ###

N,K=map(int,input().split())
S=input()

#K=1
#S="01100"
#N=len(S)

LIST=[[[0] for j in range (2)]for i in range(N)]

t=S[0]
c=0
k=0
for i in range(N):
    if(t!=S[i]):
        LIST[k][0]=c
        LIST[k][1]=t
        t=S[i]
        k+=1
        c=0
    c+=1

LIST[k][0]=c
LIST[k][1]=t
LIST=LIST[0:k+1]
MAX=0

s=0
l=0
r=0

if(LIST[r][1]=="1"):
    s+=LIST[r][0]
    r+=1
x=0
while(K>0 and len(LIST)>r):
    s+=LIST[r][0]
    K-=1
    if(len(LIST)-1==r):
        x=1
        break
    r+=1
    s+=LIST[r][0]
    if(len(LIST)-1==r):
        x=1
        break
    r+=1

MAX=max(s,MAX)

f=0
if(x==0):
    while(r<len(LIST)):
        if(l< len(LIST)-1):
            s-=LIST[l][0]
            l+=1
            f=1
        if(l<len(LIST)-1 and LIST[l][1]=="0"):
            s-=LIST[l][0]
            l+=1

        if(f==0):
            break
        

        s+=LIST[r][0]
        MAX=max(s,MAX)
        r+=1
        if(len(LIST)==r):
            break
        
        s+=LIST[r][0]
        MAX=max(s,MAX)
        r+=1
        if(len(LIST)==r):
            break

print(MAX)
### BUGGY CODE ###

n = input()
a = list(map(int, input().split()))
sum = 0

for i in range(len(a)):
    for j in range(len(a)):
        if i<j:
            sum += a[i] * a[j]
    
print(sum%1000000007)

### FIXED CODE ###

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

for i in range(len(a)):
    b -= a[i]
    sum += a[i]*b   

print(sum%(10**9+7))
### BUGGY CODE ###

N, K = map(int, input().split())
p = tuple(map(int, input().split()))

max = 0
ite = N - K
base = sum(p[0:K])
max = base
index = 0
for i in range(ite):
    tmp = base + p[i+K] - p[i]
    if tmp > max:
        max = tmp
        index = i+1
    base = tmp

E = [None]*K
for i in range(K):
    E[i] = sum(range(1, p[index+i]+1))/p[index+i]
print(sum(E))

### FIXED CODE ###

import sys

N, K = map(int, sys.stdin.readline().split())
p = tuple(map(int, sys.stdin.readline().split()))

max = 0
ite = N - K
base = sum(p[0:K])
max = base
index = 0
for i in range(ite):
    tmp = base + p[i+K] - p[i]
    if tmp > max:
        max = tmp
        index = i+1
    base = tmp

E = [(1+p[index+i])/2 for i in range(K)]
print(sum(E))
### BUGGY CODE ###

N = int(input())
P = list(map(float, input().split()))
dp = [[0 for _ in range(N+1)] for _ in range(1, N+1, 2)]

dp[0][0], dp[0][1] = 1-P[0], P[0]
for i in range(0, (N-1)//2):
    hh, tt = P[2*i+1] * P[2*i+2], (1 - P[2*i+1]) * (1 - P[2*i+2])
    ht = 1 - hh - tt
    for j in range(0, 2*i+2):
        dp[i+1][j+2] += hh * dp[i][j]
        dp[i+1][j+1] += ht * dp[i][j]
        dp[i+1][j] += tt * dp[i][j]
print(sum(dp[(N-1)//2][(N+1)//2:]))

### FIXED CODE ###

N = int(input())
P = list(map(float, input().split()))
dp = [[0 for _ in range(N+1)] for _ in range(1, N+1, 2)]

dp[0][0], dp[0][1] = 1-P[0], P[0]
for i in range(0, (N-1)//2):
    hh, tt = P[2*i+1] * P[2*i+2], (1 - P[2*i+1]) * (1 - P[2*i+2])
    ht = 1 - hh - tt
    for j in range(0, 2*i+2):
        dp[i+1][j+2] += hh * dp[i][j]
        dp[i+1][j+1] += ht * dp[i][j]
        dp[i+1][j] += tt * dp[i][j]
print(sum(dp[(N-1)//2][(N+1)//2:]))
### BUGGY CODE ###

h, n = map(int, input().split())
ab = []
for _ in range(n):
  a, b = map(int, input().split())
  ab.append((a, b))
dp = [0] * (h+1)
for c in range(1, h+1):
  dp[c] = min([dp[max(0, c-a)] + b for a, b in ab])
print(dp[-1])

### FIXED CODE ###

h, n = map(int, input().split())
dp = [[0] * (h+1) for i in range(n)]
a, b = map(int, input().split())
for c in range(1, h+1):
  dp[0][c] = b * ((c-1) // a + 1)
for i in range(1, n):
  a, b = map(int, input().split())
  for c in range(1, h+1):
    opt1 = dp[i-1][c]
    opt2 = dp[i-1][max(0, c-a)] + b
    opt3 = dp[i][max(0, c-a)] + b
    dp[i][c] = min(opt1, opt2, opt3)
print(dp[-1][-1])
### BUGGY CODE ###

def gcd(a, b):
    if a < b:
        a, b = b, a
    return b if a % b == 0 else gcd(b, a%b)

def solve(n, a):
    ok = True
    p = a[0]
    for i in range(1, n):
        q = gcd(p, a[i])
        if q > 1:
            ok = False
            break
        p = p * a[i] // q
    if ok:
        return "pairwise coprime"
    p = a[0]
    for i in range(1, n):
       p = gcd(p, a[i])
    return "setwise coprime" if p == 1 else "not coprime"

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))


### FIXED CODE ###

from math import gcd
from functools import reduce
NUM_MAX = 10**6 + 1
def solve(n, a):
    c = [0] * NUM_MAX
    for x in a:
        c[x] += 1
    t = any(sum(c[i::i]) > 1 for i in range(2, NUM_MAX))
    t += reduce(gcd, a) > 1
    return ["pairwise", "setwise", "not"][t] + " coprime"

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

def dfs(v, p, tree, ans):
    for u in tree[v]:
        if u == p:
            continue
        ans[u] += ans[v]
        dfs(u, v, tree, ans)

def main():
    N, Q = map(int, input().split())
    tree = [[] for _ in range(N)]
    for i in range(N - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        tree[a].append(b)
        tree[b].append(a)
    ans = [0] * N
    for i in range(Q):
        p, x = map(int, input().split())
        p -= 1
        ans[p] += x

    dfs(0, -1, tree, ans)

    print(*ans)

main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

def dfs(v, p, tree, ans):
    for u in tree[v]:
        if u == p:
            continue
        ans[u] += ans[v]
        dfs(u, v, tree, ans)

def main():
    N, Q = map(int, input().split())
    tree = [[] for _ in range(N)]
    for i in range(N - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        tree[a].append(b)
        tree[b].append(a)
    ans = [0] * N
    for i in range(Q):
        p, x = map(int, input().split())
        p -= 1
        ans[p] += x

    dfs(0, -1, tree, ans)

    print(*ans)

main()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)
from collections import deque


N, M = map(int, input().split())
tree = [[] for i in range(N)]
for i in range(N-1):
  x, y = map(int, input().split())
  tree[x-1].append(y-1)
  tree[y-1].append(x-1)


dp1 = [0] * N
dp2 = [0] * N

def solve(node, parent):
  global dp1
  if dp1[node] > 0:
    return dp1[node]
  else:
    children = tree[node]
    t = 1
    for child in children:
      if child == parent:
        continue
      t *= (solve(child, node) + 1)
      # t %= M
    
    dp1[node] = t
    return t


_ = solve(0, -1)

dp2[0] = dp1[0]
d = deque([])
for child in tree[0]:
  d.append([child, 0])

while d:
  node, parent = d.popleft()
  dp2[node] = (dp2[parent]//(dp1[node]+1) + 1) * dp1[node]
  children = tree[node]
  for child in children:
    if child == parent:
      continue
    
    d.append([child, node])

for ans in dp2:
  print(ans%M)

### FIXED CODE ###

# 参考 -> https://atcoder.jp/contests/dp/submissions/8271798

import itertools
import sys
input = sys.stdin.readline

N, MOD = map(int, input().split())
XY = [list(map(int, input().split())) for i in range(N-1)]
prod = lambda x, y: x*y%MOD

tree = [[] for i in range(N)]
for x, y in XY:
  tree[x-1].append(y-1)
  tree[y-1].append(x-1)

root = 0
parent = [-1] * (N+1)
order = []
stack = [root]
while stack:
  node = stack.pop()
  order.append(node)
  for child in tree[node]:
    if child == parent[node]:
      continue
    parent[child] = node
    stack.append(child)

# dp_down[i] : 頂点iを黒く塗ったときの子側の塗り方
dp_down = [0] * N
for node in order[::-1]: # 葉から根に向かって伝搬させる
  res = 1
  for child in tree[node]:
    res *= dp_down[child] + 1
    res %= MOD
  dp_down[node] = res

# dp_up[i] : 頂点iを黒く塗ったときの親側の塗り方
dp_up = [1] * N
for node in order: # 根から葉に向かって伝搬させる
  par = parent[node]
  arr = [dp_down[c]+1 if c!=par else dp_up[node] for c in tree[node]]
  # それぞれの子(=c)について、自身を根とする下側の部分木を除いた積
  left = [1] + list(itertools.accumulate(arr, prod))[:-1]
  right = list(itertools.accumulate(reversed(arr), prod))[-2::-1] + [1]
  upper_cases = [l*r%MOD for l, r in zip(left, right)]
  for c, res in zip(tree[node], upper_cases):
    if c != par:
      dp_up[c] = res + 1 # (+1 : cより上側が全て白である場合を足し合わせる)

ans = [d*u%MOD for d, u in zip(dp_down, dp_up)]
print(*ans, sep='\n')
### BUGGY CODE ###

n = int(raw_input())
ls = []
for i in range(n):
    cmd = raw_input()
    if cmd[0] == "i":
        ls.append(int(cmd[6:]))
    elif cmd[6] == "F":
        del ls[len(ls)-1:]
    elif cmd[6] == "L":
        del ls[:1]
    else:
        try:
            p = ls[::-1].index(int(cmd[7:]))
            if p != -1:
                del ls[-p-1]
        except:
            pass
print " ".join(map(str, ls[::-1]))

### FIXED CODE ###

n = int(raw_input())
ls = []
bp = 0
for i in range(n):
	cmd = raw_input()
	if cmd[0] == "i":
		ls.append(cmd[7:])
	elif cmd[6] == " ":
		try:
			x = ls[::-1].index(cmd[7:])
			if x!=-1:
				del ls[-x-1]
		except:
			pass
	elif cmd[6] == "F":
		ls.pop()
	else:
		bp += 1

print " ".join(map(str, ls[bp:][::-1]))
### BUGGY CODE ###

if __debug__:
  i = 0
  while True:
    i *= 2

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

print(2**M*(1900*M+100*(N-M)))

### FIXED CODE ###


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

print(2**M*(1900*M+100*(N-M)))
### BUGGY CODE ###

N=int(input())
lis=[]
ans=0
for i in range(N):
	x=input()
	try:
		y=lis.index(x)
	except:
		lis+=[x]
		ans+=1
print(ans)


### FIXED CODE ###

N=int(input())
lis=[]
ans=0
for i in range(N):
	lis+=[input()]
print(len(set(lis)))
### BUGGY CODE ###

N =int(input())
L = list(map(int,input().split()))
A=1
for i in range(N):
    if 0 in L:
        print(0)
        break
    A = A * L[i]
    if i == N-1 and A <= 10**18:
        print(A)
    elif A > 10**18:
        break
if A > 10**18:
    print(-1)
        

### FIXED CODE ###

N = int(input())
Alist = list(map(int,input().split()))
Answer = 1
if 0 in Alist:
    Answer = 0
for i in range(N):
    Answer *= Alist[i]
    if Answer > 10**18:
        Answer = -1
        break
print(Answer)
### BUGGY CODE ###

from operator import mul
from functools import reduce
 
n = int(input())
lis = list(map(int, input().split()))
 
ans = reduce(mul, lis)
 
if ans > 10**18:
    print("-1")
else:
    print(ans)

### FIXED CODE ###

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

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

ans = 1
for i in lis:
    ans *= i
    if ans >= 10**18:
        break

if ans > 10**18:
    print("-1")
else:
    print(ans)
### BUGGY CODE ###

import itertools
import functools
import math
from collections import Counter
from itertools import combinations

def CHK():
    S=list(input())
    Q=int(input())

    rflg = 0
    for i in range(Q):
        Que = input()
        if Que == '1':
            if rflg == 0:
                rflg = 1
            else:
                rflg = 0
            #S= list(reversed(S))
        else:
            T,F,C=map(str,Que.split())
            if F == '1' and rflg == 0 or (F != '1' and rflg == 1):
                S=list(C)+S
            else:
                S.append(C)

    if rflg == 1:
        S = list(reversed(S))
    print("".join(S))

CHK()


### FIXED CODE ###

import itertools
import functools
import math
from collections import Counter
from itertools import combinations

def CHK():
    S=list(input())
    Q=int(input())
    H=""
    B=""
    rflg = 0
    for i in range(Q):
        Que = input()
        if Que == '1':
            if rflg == 0:
                rflg = 1
            else:
                rflg = 0
            #S= list(reversed(S))
        else:
            T,F,C=map(str,Que.split())
            if F == '1' and rflg == 0 or (F != '1' and rflg == 1):
                #S=list(C)+S
                H = C + H
            else:
                #S.append(C)
                B = B + C

    S = list(H) + S + list(B)
    if rflg == 1:
        S = list(reversed(S))
    print("".join(S))

CHK()
### BUGGY CODE ###

N, M = map(int, input().split())
a = list(map(int, input().split()))
a = list(set(a))
N = len(a)
for k in range(N):
  a[k] //= 2


count = 0
foo = 1

while a[0]%2 == 0:
  foo *= 2
  a[0] // 2
for k in range(1, N):
  if a[k] % foo == 0 and a[k]%(2*foo) !=0:
    a[k] //= foo
    continue
  else:
    print(0)
    exit()
ans = 0

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

a.sort(reverse=True)
lcm = a[0]
for k in range(1, N):
  lcm = lcm * a[k] // euclid(lcm, a[k])
  if lcm* foo > M:
    print(0)
    exit()
lcm *= foo
ans = int((M / lcm -1)//2 + 1)
print(ans)


### FIXED CODE ###

N, M = map(int, input().split())
a = list(map(int, input().split()))
for k in range(N):
  a[k] //= 2

foo = 1
while a[0]%2 == 0:
  foo *= 2
  a[0] //= 2
for k in range(1, N):
  if a[k] % foo == 0 and a[k]%(2*foo) !=0:
    a[k] //= foo
    continue
  else:
    print(0)
    exit()
ans = 0

import math
lcm = a.pop()
for k in range(1, N):
  b = a.pop()
  lcm = lcm * b // math.gcd(lcm, b)
  if lcm* foo > M:
    print(0)
    exit()
lcm *= foo
ans = int((M / lcm -1)//2 + 1)
print(ans)
### BUGGY CODE ###

import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)


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


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


total = Counter()
two_count = None
for a in A:
    primes = Counter(prime_factorize(a))
    if not two_count:
        two_count = primes[2]
    elif two_count != primes[2]:
        print(0)
        exit()

    for k, v in primes.items():
        total[k] = max(total[k], primes[k])

ans = 1
for k, v in total.items():
    ans *= pow(k, v)
    if ans > 2*m:
        print(0)
        exit()
# print(ans)

print((m - ans//2)//ans + 1)


### FIXED CODE ###

import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
# import math
from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)


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


def lcm_base(x, y):
    # return (x * y) // math.gcd(x, y)
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    x = 1
    for i in range(n):
        x = lcm_base(x, numbers[i])
        if x > 2*m:
            print(0)
            exit()

    return x


def count_two(x):
    count = 0
    while x%2 == 0:
        count += 1
        x //= 2
    return count


two_count = count_two(A[0])
for a in A[1:]:
    if two_count != count_two(a):
        print(0)
        exit()

LCM = lcm_list(A)
# print(LCM)
print((m - LCM//2)//LCM + 1)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input(). split()))
prod = 1
for a in A:
    if a == 0:
        prod = 0
    prod *= a
    if prod > 1000000000000000000:
        prod = -1
print(prod)

### FIXED CODE ###

def main():
    n = int(input())
    A = [int(x) for x in input().split()]
    if 0 in A:
        print(0)
        return

    mul = 1
    for a in A:
        mul *= a

        if mul > 1e18:
            print(-1)
            return

    print(mul)


main()
### BUGGY CODE ###

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

prd = 1
for i in range(N):
  prd *= A[i]
if(prd > 10**18):
  print(-1)
else:
  print(prd)

### FIXED CODE ###

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

if 0 in A:
  print(0)
  exit()
else:
  flag = True
  prd = 1
  A.sort(reverse=True)
  for i in range(N):
    prd *= A[i]
    if prd > 10**18:
      flag = False
      break
if flag:
  print(prd)
else:
  print(-1)
### BUGGY CODE ###

#D
H=int(input())
cnt=1
ans=1
while True:
    H=int((H-H%2)/2)
    ans+=pow(2,cnt)
    cnt+=1
    if H==1:
        break
print(ans)

### FIXED CODE ###

#D
H=int(input())
cnt=0
ans=0
while True:
    ans+=pow(2,cnt)
    cnt+=1
    if H==1:
        break
    H=int((H-H%2)/2)
print(ans)