Harryxun/stf_run huggingface dataset:
N = int(input())
G = {i:[] for i in range(N)}
for i in range(N-1):
  u, v, w = list(map(int, input().split()))
  u -= 1
  v -= 1
  w = w % 2
  G[u].append([v, w])
  G[v].append([u, w])
res = [0] * N

def dfs(u, p, c):
  res[u] = c
  for n in G[u]:
    if n[0] == p:
      continue
    if n[1]:
      dfs(n[0], u, (c+1)%2)
    else:
      dfs(n[0], u, c)
  
def main():
  dfs(0, -1, 0)
  for i in res:
    print(i)
  
  
if __name__ == "__main__":
  main()

### FIXED CODE ###

N = int(input())
G = [[] for i in range(N)]
for i in range(N-1):
  u, v, w = list(map(int, input().split()))
  u -= 1
  v -= 1
  w = w % 2
  G[u].append([v, w])
  G[v].append([u, w])
  
res = [-1] * N
"""
def dfs(u, p, c):
  res[u] = c
  for n in G[u]:
    if n[0] == p or res[n[0]] != -1:
      continue
    if n[1] == 1:
      dfs(n[0], u, 1-c)
    else:
      dfs(n[0], u, c)
"""
from collections import deque
q = deque()
# 再帰はメモリ的に厳しい？？
def search(q):
  while q:
    u, p, c = q.popleft()
    if res[u] == -1:
      for n in G[u]:
        if n[0] == p or res[n[0]] != -1:
          continue
        if n[1] == 1:
          q.append((n[0], u, 1-c))
        else:
          q.append((n[0], u, c))
    res[u] = c
  
  
def main():
  q.append((0, -1, 1))
  search(q)
  for i in res:
    print(i)
  
  
if __name__ == "__main__":
  main()
n, q = map(int, input().split())
s = str(input())
lr = []
for i in range(q):
    lr.append(list(input().split()))

n = len(s)
ary = [0 for i in range(lne(s)+1)]

for i in range(1, N):
    if s[i-1] == 'A' and s[i] == 'C':
        ary[i+1] = ary[i] + 1
    else:
        ary[i+1] = ary[i]

for i in range(q):
    ans = ary[lr[i][0]] - ary[lr[i][1]]
    print(ans)


### FIXED CODE ###

n, q = map(int, input().split())
s = str(input())
lr = []
for i in range(q):
    lr.append(list(input().split()))

n = len(s)
ary = [0 for i in range(len(s)+1)]

for i in range(1, n):
    if s[i-1] == 'A' and s[i] == 'C':
        ary[i+1] = ary[i] + 1
    else:
        ary[i+1] = ary[i]

for i in range(q):
    ans = ary[int(lr[i][1])] - ary[int(lr[i][0])]
    print(ans)
inpl = lambda: list(map(int,input().split()))
X = int(input())
if X < 100:
    print(0)
elif X <= 105:
    print(1)
dp = [False]*(X+1)
goods = list(range(100,106))
dp[0] = True
for k in goods:
    dp[k] = True

for i in range(200, X+1):
    for k in goods:
        if dp[i-k]:
            dp[i] = True
            break
if dp[X]:
    print(1)
else:
    print(0)

### FIXED CODE ###

inpl = lambda: list(map(int,input().split()))
X = int(input())
if X < 100:
    print(0)
    exit()
elif X <= 105:
    print(1)
    exit()
dp = [False]*(X+1)
goods = list(range(100,106))
dp[0] = True
for k in goods:
    dp[k] = True

for i in range(200, X+1):
    for k in goods:
        if dp[i-k]:
            dp[i] = True
            break
if dp[X]:
    print(1)
else:
    print(0)
Sd = input()
T = input()
Sd = list(Sd)
N = len(Sd)

start_idxs = []
is_t_ing = 0
counter = 0
for i in range(N):
    if counter == len(T):
        is_t_ing = 0
        counter = 0

    if not is_t_ing:
        if Sd[i] == T[0]:
            is_t_ing = 1
            start_idxs.append(i)
            counter = 1
    else:
        if Sd[i] == "?" or Sd[i] == T[counter]:
            counter += 1
        else:
            is_t_ing = 0
            counter = 0
            start_idxs.pop()
S_list = []
if len(start_idxs) > 0:
    for start_idx in start_idxs:
        tmp_string = Sd.copy()
        for i in range(len(T)):
            tmp_string[start_idx + i] = T[i]
        tmp_string = "".join(tmp_string)
        tmp_string = tmp_string.replace("?", "a")
        S_list.append(tmp_string)
    ans = min(S_list)
    print(ans)
else:
    tmp_string = Sd.copy()
    tmp_string = "".join(tmp_string)
    tmp_string = tmp_string.replace("?"*len(T), T)
    if tmp_string == "".join(Sd):
        print("UNRESTORABLE")
    else:
        print(tmp_string.replace("?", "a"))


### FIXED CODE ###

S = input()
T = input()

partial_s = []
for i in range(len(S)-len(T)+1):
    partial_s.append(S[i:i+len(T)])
to_replace_idxs = []

for idx, sub_s in enumerate(partial_s):
    for i in range(len(sub_s)):
        flag = 1
        if sub_s[i] != T[i]:
            if sub_s[i] != "?":
                flag = 0
                break
    if flag:
        to_replace_idxs.append(idx)

tmp_ans = []
if not to_replace_idxs:
    print("UNRESTORABLE")
else:
    for to_replace_idx in to_replace_idxs:
        tmp_string = S
        tmp_string = list(tmp_string)
        for i in range(to_replace_idx, to_replace_idx+len(T)):
            tmp_string[i] = T[i-to_replace_idx]
            
        tmp_string = "".join(tmp_string)
        tmp_string = tmp_string.replace("?", "a")
        tmp_ans.append(tmp_string)
    print(min(tmp_ans))
n=int(input())
h=list(map(int,input().split()))
count=0
while h.count(0)!=len(h):
  stack=[]
  substack=[]
  for i in range(len(h)):
    if h[i]!=0:
      substack.append(i)
    else:
      substack.append(i)
      stack.append(substack)
      substack=[]
  h=[]
  for i in range(len(stack)):
    count+=min(i)
    h+=i
print(count)

### FIXED CODE ###

n=int(input())
h=list(map(int,input().split()))
count=0
while h.count(0)!=len(h):
  stack=[]
  substack=[]
  for i in range(len(h)):
    if h[i]!=0:
      substack.append(h[i])
    else:
      if len(substack)>0:
        stack.append(substack)
      stack.append([0])
      substack=[]
  if len(substack)>0:
    stack.append(substack)
  h=[]
  for i in range(len(stack)):
    if max(stack[i])==0:
      h+=stack[i]
      continue
    x=min(stack[i])
    count+=x
    for j in range(len(stack[i])):
      stack[i][j]-=x
    h+=stack[i]
print(count)
N = int(input())
A = [int(i) for i in input().split()]


def solve(A):
    dict_A = {key: val for key, val in zip(A, range(N))}
    score_sorted = sorted(dict_A.items(), key=lambda x : x[1])
    score_sorted = dict(score_sorted)

    return ' '.join(list(score_sorted.keys()))


print(solve(A))


### FIXED CODE ###

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

index = 1
dic = {}

for i in A:
    dic[i] = index
    index += 1

sort_dic = sorted(dic.items(), key=lambda x:x[0])

for i in sort_dic:
    print(i[1], end = ' ')
a = int(input())
b = int(input())

if a < b:
  print('LESS'):
elif a > b:
  print('GREATER')
else:
  print('EQUAL')

### FIXED CODE ###

a = int(input())
b = int(input())

if a < b:
  print('LESS')
elif a > b:
  print('GREATER')
else:
  print('EQUAL')
data = input()
target = input()

start = 0
flag = "No"
for i in target:
    if(data[start:].find(i)):
        start = data[start:].find(i)
    elif(data[:start].find(i)):
        start = data.[:start].find(i)
    else:
        print("No")
        break
    if(i == target[-1]):
        print("Yes")
        break


### FIXED CODE ###

s = input()*2
p = input()
print("Yes" if p in s else "No")
from collections import Counter
from math import min

N = int(input())

arr = [input() for i in range(0,N)]

odd = arr[0::2]
even = arr[1::2]

odd_counter = Counter(odd)
even_counter = Counter(even)

odd_mode = odd_counter.most_common()[0][0]
even_mode = even_counter.most_common()[0][0]

odd_diff = (N / 2) - odd_counter.most_common()[0][1]
even_diff = (N / 2) - even_counter.most_common()[0][1]

if odd_mode != even_mode:
	print(odd_diff + even_diff)
else:
 	odd_diff2 = (N / 2) - odd_counter.most_common()[1][1]
	even_diff2 = (N / 2) - even_counter.most_common()[1][1]
    if odd_diff2 > even_diff2:
		print(odd_diff + even_diff2)
    else:
		print(odd_diff2 + even_diff)

### FIXED CODE ###

from collections import Counter

N = int(input())

arr = list(map(int, input().split(' ')))

odd = arr[0::2]
even = arr[1::2]

odd_counter = Counter(odd)
even_counter = Counter(even)

odd_mode = odd_counter.most_common()[0][0]
even_mode = even_counter.most_common()[0][0]

odd_diff = (N / 2) - odd_counter.most_common()[0][1]
even_diff = (N / 2) - even_counter.most_common()[0][1]

if odd_mode != even_mode:
	print(int(odd_diff + even_diff))
elif odd_diff == 0:
	print(int(N / 2))
else:
	odd_diff2 = (N / 2) - odd_counter.most_common()[1][1]
	even_diff2 = (N / 2) - even_counter.most_common()[1][1]
	if odd_diff2 > even_diff2:
		print(int(odd_diff + even_diff2))
	else:
		print(int(odd_diff2 + even_diff))
a, b, c = list(map(int, input().split()))

big = max([a,b,c])

print(sum[a,b,c] + 9*big)

### FIXED CODE ###

def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

a,b,c = getlist()
m = max([a,b,c])
print(10*m + a+ b+ c -m)
L,R,d = (int(x) for x in input().split())

for i in range(R):
    if d*i>=R:
      max=i
      break

for i in range(L):
    if d*i>=L:
        min=i-1
        break

print(str(max-min))

### FIXED CODE ###

L,R,d = (int(x) for x in input().split())
cnt=0
for i in range(L,R+1):
 if i%d==0:
        cnt+=1

print(cnt)
n=input()
A=input()
B=input()
z=A+B
if n%z<=A:
    print(int(n/z)*A+n%z)
elif A<=n%z<=z:
    print(int(n/z)*A)

### FIXED CODE ###

n,A,B=map(int,input().split())
z=A+B
if n%z<=A:
    print(int(n/z)*A+n%z)
elif A<=n%z<=z:
    print(int(n/z)*A+A)
N=int(input())
p=list(map(int, input().split()))
cnt=0
min=p[0]
for i in range(N):
	if p[i]<=min:
		min=p[i]
        cnt+=1
        
print(cnt)

### FIXED CODE ###

N=int(input())
p=list(map(int, input().split()))
 
cnt=0
min=p[0]
for i in range(N):
	if p[i]<=min:
		min=p[i]
		cnt+=1
	
print(cnt)
n, m = map(int, input().split())
adj = [[] for _ in range(m)]
for _ in range(m):
  x, y, z = map(int, input().split())
  adj[x-1].append(y-1)
  adj[y-1].append(x-1)
opn = [True] * n
count = 0
for i in range(n):
  if opn:
    count += 1
    opn[i] = False
    stack = [i]
    while stack:
      u = stack.pop()
      for v in adj[u]:
        if opn[v]:
          stack.append(v)
          opn[v] = False
print(count)

### FIXED CODE ###

n, m = map(int, input().split())
adj = [[] for _ in range(n)]
for _ in range(m):
  x, y, z = map(int, input().split())
  adj[x-1].append(y-1)
  adj[y-1].append(x-1)
opn = [True] * n
count = 0
for i in range(n):
  if opn[i]:
    count += 1
    opn[i] = False
    stack = [i]
    while stack:
      u = stack.pop()
      for v in adj[u]:
        if opn[v]:
          stack.append(v)
          opn[v] = False
print(count)
= input().split(" ")
n = int(nm[0])
m = int(nm[1])
 
a = input().split(" ")
 
total = 0
for v in a:
  total += int(v)
  
mv = total / (4 * m)
q = 0
for e in a:
  e = int(e)
  if e >= mv:
    q += 1
    
if q >= m:
  print("Yes")
else:
  print("No")
 

### FIXED CODE ###

nm = input().split(" ")
n = int(nm[0])
m = int(nm[1])
 
a = input().split(" ")
 
total = 0
for v in a:
  total += int(v)
  
mv = total / (4 * m)
q = 0
for e in a:
  e = int(e)
  if e >= mv:
    q += 1
    
if q >= m:
  print("Yes")
else:
  print("No")
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
bool check(vector<string> A, string S){
     for(string x : A) {
        if(S == x) return false;
    }
    return true;
}

int main(){
    int N, count = 0;
    string S;  
    cin >> N;
    vector<string> A(N);
    for(int i=0;i<N;i++){
        cin >> S;
        if(check(A,S)){
            A.push_back(S);   
            count++;
        }  
    }
    cout << count << endl;
}

### FIXED CODE ###

N = int(input())
L = set({})
for i in range(N):
    L.add(input())
print(len(L))
k = int(input())
a,b = map(int,input().split())
for i in range(a,b+1):
	if i%k == 0:
    	print('OK')
        exit()
print('NG')

### FIXED CODE ###

k = int(input())
a,b = map(int,input().split())
for i in range(a,b+1):
    if i%k == 0:
        print('OK')
        exit()
print('NG')
N = int(input())
Alist = list(map(int, input().split()))
V = [0 for v in range(N)]
for i in range(1,N+1):
  A = Alist[i]
  V[A] += i
print(' '.join(map(str,V)))

### FIXED CODE ###

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

print(' '.join(map(str,V)))
a,b=map(int, input().split())
c = (b-1) / (a-1)

if( (b-1) % (a-1) > 0):
   c = c+1
print(c)

### FIXED CODE ###

predict, actual = input(),input()
a = 0
for i in range(3):
    if(predict[i] == actual[i]):
        a = a + 1
print(a)
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
  a, b = map(int, input().split())
  G[a - 1].append(b - 1)
  G[b - 1].append(a - 1)
V = []
D = 0
for i in range(N):
  if len(G[i]) % 2:
    print('No')
    break
  D = max(len(G[i], D))
  if len(G[i]) == 4:
    V.append(i)
else:
  if D >= 6:
    print('Yes')
  elif len(V) != 2:
    print('Yes' if len(V) > 2 else 'No')
  else:
    s = V[0]
    for i in range(3):
      t = G[s].pop()
      G[t].pop(G[t].index(s))
      while t not in V:
        d = G[t].pop()
        G[d].pop(G[d].index(t))
        t = d
      if s == t:
        print('Yes')
        break
      else:
        s = t
    else:
      print('No')

### FIXED CODE ###

N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
  a, b = map(int, input().split())
  G[a - 1].append(b - 1)
  G[b - 1].append(a - 1)
V = []
D = 0
for i in range(N):
  if len(G[i]) % 2:
    print('No')
    break
  D = max(len(G[i]), D)
  if len(G[i]) == 4:
    V.append(i)
else:
  if D >= 6:
    print('Yes')
  elif len(V) != 2:
    print('Yes' if len(V) > 2 else 'No')
  else:
    s = V[0]
    for i in range(3):
      t = G[s].pop()
      G[t].pop(G[t].index(s))
      while t not in V:
        d = G[t].pop()
        G[d].pop(G[d].index(t))
        t = d
      if s == t:
        print('Yes')
        break
      else:
        s = t
    else:
      print('No')
princt(int(input()) ^ 1)

### FIXED CODE ###

print(int(input()) ^ 1)
N, M, K = map(int, input().split())
friends_table = [[] for i in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    friends_table[a-1] += [b-1]
    friends_table[b-1] += [a-1]

blocks_table = [[] for i in range(N)]
for _ in range(K):
    a, b = map(int, input().split())
    blocks_table[a-1] += [b-1]
    blocks_table[b-1] += [a-1]

group_list = [i for i in range(N)]
friends_candidate = [[] for i in range(N)]

for i in range(N):
    friend = [i]
    # すでにDFS済み
    if i != group_list[i]:
        continue
    next_stack = friends_table[i].copy()
    while next_stack:
        next = next_stack.pop()
        # 訪問済み
        if i == group_list[next]:
            continue
        friend += [next]
        group_list[next] = i
        next_stack += friends_table[next]
    for f in friend:
        friends_candidate[f] = friend
        
for i in range(N):
    print(len(set(friends_candidate[i]).difference(set(friends_table[i] + blocks_table[i])))-1)

### FIXED CODE ###

import sys
input = sys.stdin.readline

N, M, K = map(int, input().split())
friends_table = [[] for i in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    friends_table[a-1] += [b-1]
    friends_table[b-1] += [a-1]

group_list = [i for i in range(N)]
friends_candidate = [[] for i in range(N)]

for i in range(N):
    # すでにDFS済み
    if i != group_list[i]:
        continue
    next_stack = [i]
    friend = [i]
    while next_stack:
        u = next_stack.pop(-1)
        for v in friends_table[u]:
            # 訪問済み
            if i == group_list[v]:
                continue
            friend += [v]
            group_list[v] = i
            next_stack += [v]
    for f in friend:
        friends_candidate[f] = friend

blocks_table = [[] for i in range(N)]
for _ in range(K):
    a, b = map(int, input().split())
    if group_list[a-1] == group_list[b-1]:
        blocks_table[a-1] += [b-1]
        blocks_table[b-1] += [a-1]

for i in range(N):
    print(len(friends_candidate[i]) - len(friends_table[i]) - len(blocks_table[i])-1)
L, R = map(int, input().split())

import numpy as np
ms = np.array(np.unique(np.arange(L, R+1) % 2019))

Ms = ms.reshape(-1,1)*ms.reshape(1,-1)
Ms = Ms % 2019
Ms += np.eye(Ms.shape[0], dtype=int)*2019
print(np.min(Ms))

### FIXED CODE ###

L, R = map(int, input().split())

import numpy as np
if L+2019<=R:
    ms = np.arange(2019)
else:
    ms = np.unique(np.arange(L, R+1) % 2019)

Ms = ms.reshape(-1,1)*ms.reshape(1,-1)
Ms = Ms % 2019
Ms += np.eye(Ms.shape[0], dtype=int)*2019
print(np.min(Ms))
import sys
N = int(input())

s = 0

while(s <= N):
    if((N - s) % 4 == 0):
        print("Yes")
        sw = 1
        sys.exit()
    s += 7


print("No")

### FIXED CODE ###

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

if(n[0] % n[1] == 0):
    print("0")
else:
    print("1")
import math

n = int(input())
kaisu = math.log2(n)
ans = 0

for i in range(kaisu):
  ans += 2 ** i

print(ans)


### FIXED CODE ###

import math
 
n = int(input())
kaisu = math.log2(n) + 1
ans = 0
 
for i in range(int(kaisu)):
  ans += 2 ** i
 
print(ans)
import math
A,B=map(int,input().split())

li=[]
base=[]
count=1

for i in range(2,math.gcd(A,B)+1):
    if min(A,B)%i==0 and max(A,B)%i==0:
        li.append(i)
        if max(A,B)%(min(A,B)//i)==0:
            li.append(min(A,B)//i)

for l in li:
    judge=True
    for k in base:
        if l%k==0:
            judge=False
            break
    if judge==True:
        count+=1
        base.append(l)
print(count)
    

### FIXED CODE ###

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

base=fractions.gcd(A,B)
count=1


for i in range(2,int(pow(base,1/2)+1)):
    if base==1:
        break
    else:
        if base%i==0:
            count+=1
            while base%i==0:
                base//=i
if base!=1:
    count+=1
print(count)
N = int(input())
S = []
for i in range(N):
  S.append(input())

A = S.count("AC")
B = S.count("WA")
C = S.count("TLE")
D = S.count("RE")

print("AC × "+A)
print("WA × "+B)
print("TLE × "+C)
print("RE × "+D)

### FIXED CODE ###

N = int(input())
S = []
for i in range(N):
  S.append(input())
 
A = S.count("AC")
B = S.count("WA")
C = S.count("TLE")
D = S.count("RE")
 
print("AC x "+str(A))
print("WA x "+str(B))
print("TLE x "+str(C))
print("RE x "+str(D))
n,m = map(int,input().split())
a = list(int(input()) for i in range(m))
dp = [0] * (n+1)
b = 0
for i in range(1,n+1):
    if a[b] == i:
        b += 1
        if b == m:
            b = 0
    else:
        if i != 1 and i != 2:
            dp[i] = dp[i-1] + dp[i-2]
        else:
            if i == 1:
                dp[1] = 1
            elif i == 2 and a[0] == 1:
                dp[2] = 1
            else:
                dp[1] = 1
                dp[2] = 2
print(dp[-1] % (10 ** 9 + 7))

### FIXED CODE ###

n,m = map(int,input().split())
a = list(int(input()) for i in range(m))
a.append(0)
dp = [0] * (n+1)
b = 0
for i in range(1,n+1):
    if a[b] == i:
        b += 1
    else:
        if i != 1 and i != 2:
            dp[i] = dp[i-1] + dp[i-2]
        else:
            if i == 1:
                dp[1] = 1
            elif i == 2 and a[0] == 1:
                dp[2] = 1
            else:
                dp[1] = 1
                dp[2] = 2
print(dp[-1] % (10 ** 9 + 7))
def main():
    a = 'ABC'
    r = 'ARC'
    s = input()
    if s == a:
        print(r)
    else:
        print(a)
    
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    a = 'ABC'
    r = 'ARC'
    s = input()
    if s == a:
        print(r)
    else:
        print(a)

if __name__ == '__main__':
    main()
import numpy as np
N,K = (int(i) for i in input().split())  
AB = [[int(i) for i in input().split()] for i in range(N-1)] 

j = 0
point = AB[0][0]
answer = K

d = []

count = 1
for i in range(len(AB)):
    if point in AB[j]:
        AB[j].pop(AB[j].index(point))
        d.append([AB[j][0], count])
        AB.pop(j)
        count += 1
    else:
        j += 1
point = d[0][0]
answer = answer * (K-d[0][1]) % (int(10**9)+7)
d.pop(0)

while len(AB) > 0:
    j = 0
    count = 2
    for i in range(len(AB)):
        if point in AB[j]:
            AB[j].pop(AB[j].index(point))
            d.append([AB[j][0], count])
            AB.pop(j)
            count += 1
        else:
            j += 1
    point = d[0][0]
    answer = answer * (K-d[0][1]) % (int(10**9)+7)
    d.pop(0)
print(answer)

### FIXED CODE ###

import numpy as np
from collections import deque

N,K = (int(i) for i in input().split())  
AB = [[int(i) for i in input().split()] for i in range(N-1)] 

Tree = [[] for _ in range(N+1)]
d = deque()

for i in range(N-1):
    a, b = AB[i]
    Tree[a].append(b)
    Tree[b].append(a)

answer = K

for i in range(len(Tree[1])):
    answer = (answer * (K - 1 - i))%(int(10**9)+7)
    d.append([1, Tree[1][i]])

Tree[1] = []

while d != deque():
    for i in range(len(d)):
        parent, child = d[0]
        Tree[child].pop(Tree[child].index(parent))
        for j in range(len(Tree[child])):
            d.append([child, Tree[child][j]])
            answer = (answer * (K - 2 - j))%(int(10**9)+7)
        d.popleft()
print(answer)
from fractions import gcd
n, m = map(int, input().split())
s = input()
t = input()
l = n * m // gcd(n, m)
a = [""]*l
for i in range(n):
    a[i*l//n] = s[i]
for i in range(m):
    if a[i*l//m] == "" or a[i*l//m] == t[i]:
        continue
    else:
        print(-1)
        exit()
print(l)

### FIXED CODE ###

from fractions import gcd
n, m = map(int, input().split())
s = input()
t = input()
g = gcd(n,m)
l = n*m//g
for k in range(g):
    if s[k*n//g] != t[k*m//g]:
        print(-1)
        exit()
print(l)
import decimal

N = int(input())

AList = [decimal.Decimal(element) for element in input().split(" ")]

result = 1

for element in AList:
    result += result * element

if result > 10 ** 18:
    print("-1")
else:
    print(result)

### FIXED CODE ###

import sys

N = int(input())
AList = input().split()

result = 1

if "0" in AList:
    print(0)
    sys.exit()
    
for element in AList:
    result = result * int(element)

    if result > 1e+18:
        print(-1)
        sys.exit()

print(result)
def comb(n,k):
  if k==0:
    return 1
  if k==1:
    return n
  if k==2:
    return n*(n-1)//2
  if k==3:
    return n*(n-1)*(n-2)//6
  return None
def cnt(n,k):
  if k==0:
    return 1
  return (comb(len(n)-1,k)*9**k
          +(int(n[0])-1)*comb(len(n)-1,k-1)*9**(k-1)
          +cnt(n[1:],k-1))
def main():
  n=input()
  k=int(input())
  print(cnt(n,k))
main()

### FIXED CODE ###

def comb(n,k):
  if k==0:
    return 1
  if k==1:
    return n
  if k==2:
    return n*(n-1)//2
  if k==3:
    return n*(n-1)*(n-2)//6
  return None
def cnt(n,k):
  if k==0:
    return 1
  if k>len(n):
    return 0
  return (comb(len(n)-1,k)*9**k
          +(int(n[0])-1)*comb(len(n)-1,k-1)*9**(k-1)
          +cnt(n[1:].lstrip('0'),k-1))
def main():
  n=input()
  k=int(input())
  print(cnt(n,k))
main()
import math

def inputlist(): return [int(i) for i in input().split()]

def kumiawase(num):
    r = 2
    return math.factorial(num) // (math.factorial(num - r) * math.factorial(r))

def main():
    N, M = inputlist()
    print(kumiawase(N) + kumiawase(M))

if __name__ == '__main__':
    main()

### FIXED CODE ###

import math

def inputlist(): return [int(i) for i in input().split()]

def kumiawase(num):
    r = 2
    if num != 1 and num != 0:
        return math.factorial(num) // (math.factorial(num - r) * math.factorial(r))
    else:
        return 0

def main():
    N, M = inputlist()
    print(kumiawase(N) + kumiawase(M))

if __name__ == '__main__':
    main()
N=int(input())
A={}
ans=0
for i in range(N):
    s=input()
    s=sorted(s)
    if A.get(s,"Not")=="Not":
        A[s]=1
    else:
        ans+=A[s]
        A[s]+=1
print(ans)

### FIXED CODE ###

N=int(input())
P=[]
for i in range(N):
    s=input()
    s=sorted(s)
    P.append(s)

P=sorted(P)
last=P[0]
cnt=0
ans=0
for i in range(1,N):
    if P[i]==last:
        cnt+=1
        ans+=cnt
    else:
        last=P[i]
        cnt=0
print(ans)
s = sum(map(int, raw_input().split(' ')))
print sum(s) + 10 *max(s)

### FIXED CODE ###

a,b,c = map(int, raw_input().split(' '))
print max(10*a + b+c, a+10*b + c, a+b + 10*c)
a, b= input().split()
print(a+b) if b%a==0 else print(b-a)

### FIXED CODE ###

a, b= map(int, input().split())
print(a+b) if b%a==0 else print(b-a)