Harryxun/stf_run huggingface dataset:
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

a,b=map(int,input().split())
ab_gcd=math.gcd(a,b)
div_list=make_divisors(ab_gcd)
prime_list=[]

for i in div_list:
    flg=True
    for j in prime_list:
        if j == 1:
            continue
        if i % j == 0:
            flg = False
            break
    if flg:
        prime_list.append(i)

print(len(prime_list))

### FIXED CODE ###

import fractions

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

a,b=map(int,input().split())
ab_gcd=fractions.gcd(a,b)
div_list=make_divisors(ab_gcd)
prime_list=[]

for i in div_list:
    flg=True
    for j in prime_list:
        if j == 1:
            continue
        if i % j == 0:
            flg = False
            break
    if flg:
        prime_list.append(i)

print(len(prime_list))
a,b,c=map(int,input().split())
print("YES" if b-a=c-b else "NO")


### FIXED CODE ###

a,b,c=map(int,input().split())
print("YES" if b-a==c-b else "NO")
def main():
  
    a, b = map(int, input().split())
    res = a * ((b+0.001) * 100) // 100
    print(int(res))
 
if __name__ == '__main__':
    main()

### FIXED CODE ###

from decimal import *
def main():
    a, b = map(str, input().split())
    res = int(a) * Decimal(b)
    print(int(res))

if __name__ == '__main__':
    main()
b = input()
if b == "A":
  pair = "T"
elif b == "T":
  pair = "A":
elif b == "C":
  pair = "G"
else:
  pair = "C"
print(pair)

### FIXED CODE ###

b = input()
if b == "A":
  pair = "T"
elif b == "T":
  pair = "A"
elif b == "C":
  pair = "G"
else:
  pair = "C"
print(pair)
from collections import gcd

N = int(input())

t = int(input())
ans = t
for _ in range(N - 1):
    tmp = int(input())
    t = gcd(ans, tmp)
    ans *= tmp
    ans //= t

print (ans)

### FIXED CODE ###

N = int(input())

def gcd(x, y):
    if x > y:
        x, y = y, x
    if y % x == 0:
        return x
    else:
        return gcd (y%x, x)


T1 = int(input())
ans = T1
for i in range(N-1):
    T2 = int(input())
    ans = T1 * T2 //gcd(T1, T2)
    T1 = ans

print (ans)

# print (gcd(12, 8))
a=int(input())

b=list(map(int, input().split()))
b.sort()
alice=0
bob=0

c=iter(b)
for i in c:
    alice=i
    bob=next(c)
print(alice-bob if alice>bob else bob-alice)

### FIXED CODE ###

a=int(input())

b=list(map(int, input().split()))
b.sort(reverse=True)
alice=0
bob=0
c=iter(b)
for i in c:
    alice+=i
    try:
    	bob+=next(c)
    except:
      break
print(alice-bob)
r=int(input())
data=(1200,2800)
name=('ABC', 'ARC', 'AGC')
z=[name[0] if r < data[0] else name[1] if data[0] <= r < data[1] else name(2) if data[1] <= r else i for i in range(1)]
print(z[0])


### FIXED CODE ###

r=int(input())

name=('ABC', 'ARC', 'AGC')
if r<1200:
  print(name[0])
elif 1200<=r<2800:
  print(name[1])
else:
  print(name[2])
# coding: utf-8
# Here your code !
ipt = input().split(" ")
j,k =0,0
for i in ipt:
    if i == 5:
        k +=1
    elif i==7:
        j += 1

if J == 1 & K == 2:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

# coding: utf-8
# Here your code !
ipt = input().split(" ")
j,k =0,0
for i in [ int(i) for i in ipt]:
    if i == 5:
        k += 1
    elif i==7:
        j += 1
#    print(ipt,i,k,j)

if j == 1 and k == 2:
    print("YES")
else:
    print("NO")
from collections import Counter
import sys
input = sys.stdin.buffer.readline

N = int(input())

def gcd(n, m):
    if m == 0:
        return n
    return gcd(m, n % m)

def make(a, b):
    s = 1 if a * b >= 0 else -1
    a, b = abs(a), abs(b)

    g = gcd(a, b)
    a //= g
    b //= g

    return (a, b, s)

ABS = Counter([make(*map(int, input().split())) for _ in range(N)])
K = list(ABS.keys())

ans = 1
MOD = 10**9 + 7

for a, b, s in K:
    p = ABS[(a, b, s)]
    n = ABS[(b, a, -s)]

    ABS[(a, b, s)] = 0
    ABS[(b, a, -s)] = 0

    cnt = pow(2, p, MOD) + pow(2, n, MOD) - 1
    ans = (ans * cnt) % MOD

print((ans - 1) % MOD)


### FIXED CODE ###

from collections import Counter
import sys
input = sys.stdin.buffer.readline

N = int(input())

def gcd(n, m):
    if m == 0:
        return n
    return gcd(m, n % m)

def make(a, b):
    if a == b == 0:
        return (0, 0, 0)
    if a == 0:
        return (0, 1, 0)
    if b == 0:
        return (1, 0, 0)

    s = 1 if a * b > 0 else -1
    a, b = abs(a), abs(b)

    g = gcd(a, b)
    a //= g
    b //= g

    return (a, b, s)

ABS = Counter([make(*map(int, input().split())) for _ in range(N)])

ans = 1
MOD = 10**9 + 7

for a, b, s in list(ABS.keys()):
    if a == b == 0:
        continue
    p = ABS[(a, b, s)]
    n = ABS[(b, a, -s)]

    ABS[(a, b, s)] = 0
    ABS[(b, a, -s)] = 0

    cnt = pow(2, p, MOD) + pow(2, n, MOD) - 1
    ans = (ans * cnt) % MOD

ans += ABS[(0, 0, 0)]

print((ans - 1) % MOD)
n, k = map(int, input().split())
print(sum(sorted(list(map(int, ipupt().split())))[:k]))


### FIXED CODE ###

n, k = map(int, input().split())
print(sum(sorted(list(map(int, input().split())))[:k]))
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())


if abs(a-b) > k or abs(b-c) > k or abs(c-d) > k or abs(d-e) > k or abs(a-d) > k
or abs(a-c) > k or abs(a-e) > k or abs(b-d) > k or abs(b-e) > k or abs(c-e) > k:
    print(":(")
else:
    print("Yay!")


### FIXED CODE ###


a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())


if abs(a-b) > k or abs(b-c) > k or abs(c-d) > k or abs(d-e) > k or abs(a-d) > k or abs(a-c) > k or abs(a-e) > k or abs(b-d) > k or abs(b-e) > k or abs(c-e) > k:
    print(":(")
else:
    print("Yay!")
a = input()
b = input()
c = input()

print(a[:1] + b[:1] + c[:1])

### FIXED CODE ###

a, b, c = map(str, input().split())

print("A" + b[:1] + "C")
import sys
s=list(input())
if s[0]!='A':
    break
count=0
for i in range(2,len(s)-2):
    if s[i]=='C':
        count+=1

if count==1:
    s.remove('A')
    s.remove('C')    
    res=''.join(s)
    print('AC' if res.islower()==True else 'WA') #str.islower():全部小文字ならTrue

else:
    print('WA')

### FIXED CODE ###

r=int(input())
if r>=2800:
    print('AGC')
elif r<1200:
    print('ABC')
else:
    print('ARC')
import numpy as np
n,m = map(int,input().split())

p = []
s = []
ans_a = np.zeros(n+1)
ans_p = np.zeros(n+1)

for i in range(m):
    pi ,si = map(str,input().split())
    p.append(int(pi))
    s.append(si)

for i in range(m):
    if s[i] == "AC":
        ans_a[p[i]] = 1
    if s[i] == "WA" and ans_a[p[i]] == 0:
        ans_p[p[i]] += 1

print(int(np.sum(ans_a)), int(np.sum(ans_p))s)


### FIXED CODE ###

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

p = []
s = []
ans_a = np.zeros(n)
ans_p = np.zeros(n)

for i in range(m):
    pi ,si = map(str,input().split())
    p.append(int(pi))
    s.append(si)

for i in range(m):
    if s[i] == "AC":
        ans_a[p[i]-1] = 1
    elif ans_a[p[i]-1] == 0:
        ans_p[p[i]-1] += 1

for i in range(n):
    if ans_a[i] == 0:
        ans_p[i] = 0

print(int(np.sum(ans_a)),int(np.sum(ans_p)))
S = input()
total = 0
for p in (product((0, 1), repeat=len(S)-1)):
    ns = S[0]
    for i, pp in enumerate(p, 1):
        if pp == 0:
            ns += S[i]
        else:
            total += int(ns)
            ns = S[i]
    total += int(ns)
print(total)




### FIXED CODE ###

import sys
import numpy as np
import math
import collections
import copy
from collections import deque 
from functools import reduce
from itertools import product

# input = sys.stdin.readline
S = input()
total = 0
for p in (product((0, 1), repeat=len(S)-1)):
    ns = S[0]
    for i, pp in enumerate(p, 1):
        if pp == 0:
            ns += S[i]
        else:
            total += int(ns)
            ns = S[i]
    total += int(ns)
print(total)
r=int(input())
if r<1200:
    print('ABC')
elif　r<2800:
    print('ARC')
else:
    print('AGC')


### FIXED CODE ###

r=int(input())
if r<1200:
    print('ABC')
elif r<2800:
    print('ARC')
else:
    print('AGC')
string = input()

v = string.split(" ")

if not len(v) == 2:
  return -1

a = int(v[0])
b = int(v[1])

if 0 < a < 10 and 0 < b < 10:
  return a * b

return -1

### FIXED CODE ###

string = input()
 
v = string.split(" ")
 
if not len(v) == 2:
  print(-1)
 
a = int(v[0])
b = int(v[1])
 
if 0 < a < 10 and 0 < b < 10:
   print(a * b)
else: 
    print(-1)
a  = int(input())
if a == 2:
    a1, a2 = map(int, input().split())
    b1, b2 = map(int, input().split())
    print()
elif a == 3:
    a1, a2, a3 = map(int, input().split())
    a1, a2, a3 = map(int, input().split())
    print(1,3)
elif a == 5:
    a1, a2, a3, a4, a5 = map(int, input().split())
    a1, a2, a3, a4, a5 = map(int, input().split())
    print(a1,a2)
    print(a1+1,a2)
    print(a1+2,a2)
    print(a1+3,a2)
    print(a1+4,a2)
elif a == 6:
    a1, a2, a3, a4, a5, a6 = map(int, input().split())
    a1, a2, a3, a4, a5, a6 = map(int, input().split())
    print(2,2)
    print(5,5)

### FIXED CODE ###

K, X = map(int, input().split())
result = K*500
if result >= X:
    print("Yes")
else:
    print("No")
n,q = list(map(int,input().split()))

import sys
sys.setrecursionlimit(100000)

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

dd_px = [0]*(n+1)
for i in range(q):
    p,x = tuple(map(int,input().split()))
    dd_px[p] += x

def add_tree(value,tree):
    for i in tree:
        dd_px[i]+=value
        add_tree(dd_px[i],dd_ab[i])
add_tree(dd_px[1],dd_ab[1])
print(*dd_px[1::])

### FIXED CODE ###

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

def main():
    N, Q = map(int, input().split())
    edges = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        edges[b-1].append(a-1)
        edges[a-1].append(b-1)

    counts = [0]*N
    for _ in range(Q):
        p, x = map(int, input().split())
        counts[p-1] += x

    parent_nodes = deque()
    parent_nodes.append(0)
    visited_nodes = set()
    while parent_nodes:
        parent = parent_nodes.popleft()
        if parent in visited_nodes:
            continue
        visited_nodes.add(parent)
        for child in edges[parent]:
            if child in visited_nodes:
                continue
            counts[child] += counts[parent]
            parent_nodes.append(child)

    print(' '.join(list(map(str, counts))))

if __name__ == "__main__":
    main()
a, b = list(map(int, input().split()))
if a > b:
  print('GREATER')
else:
  print('LESS')
  

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sat Sep  8 15:34:42 2018

@author: maezawa
"""

a = int(input())
b = int(input())
if a > b:
    print('GREATER')
elif a == b:
    print('EQUAL')
else:
    print('LESS')
print(len(set(int(input()) for i in range(int(input())))))

### FIXED CODE ###

print(input().replace('2017','2018'))
import sys
input = sys.stdin.readline
n, k = map(int, input().split())
p = list(map(int, input().split()))
p = [0] + p
c = list(map(int, input().split()))
c = [0] + c
score = [[0] * (n + 1) for _ in range(n + 1)]
# score[i][j]: iからstartしてj回移動した時のスコア
l_cycle = [0] * (n + 1)
for i in range(1, n + 1):
    start = i
    move_cnt = 0
    nxt = i
    while move_cnt < n:
        nxt = p[nxt]
        score[i][move_cnt + 1] += score[i][move_cnt] + c[nxt]
        move_cnt += 1
        if nxt == start:
            l_cycle[start] = move_cnt
            break
# for i in range(1, n + 1):
#     print(score[i])
# print('l_cycle', l_cycle)
ans = -float('inf')
for s in range(1, n + 1):
    if k <= l_cycle[s]:
        # サイクルを回らないので
        temp = max(score[s][1:k + 1])
        ans = max(ans, temp)
        continue
    # 以降は一周以上出来る時

    # 一周以下でやめる場合を探索
    temp = max(score[s][1:l_cycle[s] + 1])
    ans = max(ans, temp)
    if score[s][l_cycle[s]] <= 0:
        # 周回する意味がない
        continue
    sk = k // l_cycle[s]  # 何周出来るか
    remk = k % l_cycle[s]
    temp = sk * score[s][l_cycle[s]]  # 周回によるスコア
    temp += max(score[s][1:remk + 1])
    ans = max(ans, temp)

print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
for i in range(n):
    p[i] -= 1
ans = -float('inf')
for st in range(n):
    x = st
    score = []
    tot = 0
    while True:
        x = p[x]
        score.append(c[x])
        tot += c[x]
        if x == st:
            break
    l = len(score)
    now = 0
    t = 0
    for i in range(l):
        t += score[i]
        if i + 1 > k:
            break
        now = t
        if tot > 0:
            cycle_num = (k - (i + 1)) // l
            now += tot * cycle_num
        ans = max(ans, now)
print(ans)
def main():
	import math
	a,b,c,d = map(int,input().split())
	ans = 0
	
	e = (c*d) /math.gcd(c,d)
	# print(e)

	i = int(b/c)
	t = int(b/d)
	l = int(b/e)
	# print(i,t)
	# ans_set = set()

	while a <= i * c <= b:
		# print("i*c= {}".format(i*c))
		# ans_set.add(i*c)
		ans += 1
		i -= 1

	while a <= t * d <= b:
		# print("i*d= {}".format(t*d))
		# ans_set.add(t*d)
		ans += 1
		t -= 1
	# print(ans_set)
	
	while a <= l * e <= b:
		# print("l*c*d= {}".format(l*c*d))
		# ans_set.add(l*c*d)
		ans -= 1
		l -= 1

	print(int(len(range(a,b+1)))-ans)
	# print(int(len(range(a,b+1)))-len(ans_set))

if __name__ == "__main__":
	main()

### FIXED CODE ###

def main():
	a,b,c,d = map(int,input().split())

	#about c
	ans_c_a = (a-1)//c
	ans_c_b = b//c
	# print(ans_c_b)
	ans_c = ans_c_b - ans_c_a
	# print("ans_c = {}".format(ans_c))

	#about d
	ans_d_a = (a-1)//d
	ans_d_b = b//d
	ans_d = ans_d_b - ans_d_a
	# print("ans_d = {}".format(ans_d))

	#aboud c*d
	import fractions
	saisyou = (c * d) // fractions.gcd(c,d)
	# print(saisyou)
	ans_saisyou_a = (a-1)//saisyou
	ans_saisyou_b = b//saisyou
	ans_saisyou = ans_saisyou_b - ans_saisyou_a
	# print("ans_saisyou = {}".format(ans_saisyou))

	print(int( b-a+1 - (ans_c + ans_d - ans_saisyou) ))


if __name__ == '__main__':
	main()
a,b,n = map(int, input().split())
M = [0]*(n+1)
for i in range(n+1):
    score = int(a*i/b) - a*int(i/b)
    M[i] = score

print(max(M))

### FIXED CODE ###

a,b,n = map(int, input().split())
m = min(n,b-1)
print(int(a*m/b)-a*int(m/b))
k=int(input())
x=int(input())

if 500*k >= x:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

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

if 500*k >= x:
    print("Yes")
else:
    print("No")
print(r**2)

### FIXED CODE ###

r=int(input())
print(r**2)
n = int(input())
import math
A = list(map(int,input().split()))
g = 0
for i in range(n):
    g = math.gcd(g,A[i])
print(g)


### FIXED CODE ###

#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    import fractions
    n = int(input())
    A = readInts()
    g = fractions.gcd(A[0],A[1])
    for i in range(2,n):
        g = fractions.gcd(g,A[i])
    print(g)


if __name__ == '__main__':
  main()
if __name__ == "__main__":
  l = [0,2,5,5,4,5,6,3,7,6]
  n,m = list(map(int,input().split()))
  a = list(map(int,input().split()))
  res = ''
  INF = 10**4
  
  dp = [[0,0] for i in range(n+1)]
  for i in range(n):
    for j in range(m):
      if dp[i][1] + l[a[j]] != i + l[a[j]] or i + l[a[j]] > n:
        pass
      else:
        dp[i + l[a[j]]][0] = max(dp[i][0] + 1, dp[i + l[a[j]]][0])
        dp[i + l[a[j]]][1] = dp[i][1] + l[a[j]]
  for i in range(1,n): 
    if dp[i][0] == 0:
      dp[i][0] = -INF
    else:
      pass
  
  a.sort(reverse = True)
  i = n
  while i > 0:
    for j in range(m):
      if dp[i - l[a[j]]][0] + 1 == dp[i][0]:
        res += str(a[j])
        i -= l[a[j]]
        break
      else:
        pass
  print(res)


### FIXED CODE ###

if __name__ == "__main__":
  l = [0,2,5,5,4,5,6,3,7,6]
  n,m = list(map(int,input().split()))
  a = list(map(int,input().split()))
  res = ''
  INF = 10**4
  
  dp = [[0,0] for i in range(n+1)]
  for i in range(n):
    for j in range(m):
      if dp[i][1] + l[a[j]] != i + l[a[j]] or i + l[a[j]] > n:
        pass
      else:
        dp[i + l[a[j]]][0] = max(dp[i][0] + 1, dp[i + l[a[j]]][0])
        dp[i + l[a[j]]][1] = dp[i][1] + l[a[j]]
  for i in range(1,n): dp[i][0] = -INF if dp[i][0] == 0 else dp[i][0]
  
  a.sort(reverse = True)
  i = n
  while i > 0:
    for j in range(m):
      if i >= l[a[j]] and dp[i - l[a[j]]][0] + 1 == dp[i][0]:
        res += str(a[j])
        i -= l[a[j]]
        break
      else:
        pass
  print(res)
if len(S)<=K:
  print(K)
else:
  print(S.replace(S[K:len(S)],"..."))

### FIXED CODE ###

k=int(input())
s=str(input())

if len(s)<=k:
  print(s)
else:
    print(s[0:k]+"...")
def getinputdata():

    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = True

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:


        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])

sumdata = 0

for v in list01:
    
    sumdata += abs(v)

mytotal = 0

for v in list(map(int, arr_data[1])):
    
    if mytotal + v > sumdata // 2:
        
        break
        
    else:
        
        mytotal += v
        
print(sumdata-mytotal-mytotal)
    


### FIXED CODE ###

def getinputdata():

    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = True

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:


        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])
list01 = [int(x) for x in arr_data[1]]

sumdata = sum(list01)

middledata = sumdata // 2
#初期値
x = list01[0]
y = sumdata-x
temp=abs(x-y)

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

    x += list01[i]
    y = sumdata-x
    
    if temp>abs(x-y):
        
        temp=abs(x-y)
        
        
print(temp)
import sys

f_i = sys.stdin

n, q = map(int, f_i.readline().split())

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

for l in f_i:
    com, x, y = map(int, l.split())
    for e in S:
        if x in e and y in e:
            if com == 1:
                print(1)
            break
        elif x in e:
            if com == 0:
                ex = e
            else:
                print(0)
                break
        elif y in e:
            if com == 0:
                ey = e
            else:
                print(0)
                break
    if com == 0:
        S.append(ex + ey)
        S.remove(ex)
        S.remove(ey)

### FIXED CODE ###

import sys
 
f_i = sys.stdin
 
n, q = map(int, f_i.readline().split())

class DisjointSets:
    def __init__(self, size):
        # negative values are roots(representatives of each tree)
        # positive values represent the parent element
        self.table = [-1 for _ in range(size)]

    def _find(self, x):
        while self.table[x] >= 0:
            x = self.table[x]
        return x

    def union(self, x, y):
        s1 = self._find(x)
        s2 = self._find(y)
        if s1 != s2:
            if self.table[s1] < self.table[s2]: # the smaller has more elements
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2

    def isSameSet(self, x, y):
        if self._find(x) == self._find(y):
            print(1)
        else:
            print(0)

S = DisjointSets(n)

for l in f_i:
    com, x, y = map(int, l.split())
    if com == 0:
        S.union(x, y)
    else:
        S.isSameSet(x, y)
N.d = map(int,input().split())

if N%(2*d+1)==0:
  print(N/(2*d+1))
else:
  print((N/(2*d+1))+1)

### FIXED CODE ###

N,d = map(int,input().split())
 
if N%(2*d+1)==0:
  print(int(N/(2*d+1)))
else:
  print(int((N/(2*d+1))+1))
x = int(input())
if x == 1:
  print(0,-1)
  exit()
  
def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

c = []
fct = factorize(x)
for div in divisorize(fct):
    c.append(num(div))
    
chk = False
for s in c:
  if chk:
    break
  for i in range(1000):
    if (i+s)**5-i**5 > x:
      break
    if (i+s)**5-i**5 == x:
      ans = (i+s,i)
      chk = True
      break
  if s <1000:    
    for p in range(s,1000):
      j = -1*p
      #print(s,(j+s)**5-j**5)
      if (j+s)**5-j**5 > x:
        break 
      if (j+s)**5-j**5 == x:
        ans = (j+s,j)
        chk = True
        break 
  for ww in range(1,(s+1)//2):
    jj = -1*ww
    if (jj+s)**5-jj**5 > x:
      break    
    if (jj+s)**5-jj**5 == x:
      ans = (jj+s,jj)
      chk = True
      break 
print(*ans)


### FIXED CODE ###

s = input()
if s == 'ABC':
  print('ARC')
else:
  print('ABC')
n = int(input())
s = input()
l = len(s)

INF = float('inf')
dp = [[INF]*2 for _ in range(l+1)]
dp[0][0]=0
dp[0][1]=1
for i in range(l):
    num = int(s[i])
    dp0 = dp[i][0]
    dp1 = dp[i][1]
    dp[i+1][0] = min(dp0+num, dp1+min(10-num,num+1))
    dp[i+1][1] = min(dp0+num+1,dp1+10-num-1)

print(dp[-1][0])


### FIXED CODE ###

s = input()
l = len(s)

INF = float('inf')
dp = [[INF]*2 for _ in range(l+1)]
dp[0][0]=0
dp[0][1]=1
for i in range(l):
    num = int(s[i])
    dp0 = dp[i][0]
    dp1 = dp[i][1]
    dp[i+1][0] = min(dp0+num, dp1+min(10-num,num+1))
    dp[i+1][1] = min(dp0+num+1,dp1+10-num-1)

print(dp[-1][0])
n, m = map(int, input().split())


c = 0
a = 0

t = [0]*(n+1)

temp = []


for i in range(m):
    s = input().split()
    x = s[0]
    y = s[1]
    if y == 'AC' x not in temp:
        a += 1
        c += t[int(x)]
        temp += [x]
    elif y == 'WA':
        t[int(x)] += 1

print(a, c)


### FIXED CODE ###

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

a = [0] * (n+1)
b = [0] * (n+1)

c = 0

for i in [0]*(m):

    s = input().split()

    if a[int(s[0])] == 0:
        if s[1] == "AC":
            a[int(s[0])] = 1
            c += b[int(s[0])]
        else:
            b[int(s[0])] += 1

print(sum(a), c)
n,m=map(int,input().split())
sitei=[]
for i in range(m):
    a,b=map(int,input().split())
    sitei.append([a-1,b])

ans=[-1]*n

kano=True
for i in range(m):
    if(ans[sitei[i][0]]==-1):
        ans[sitei[i][0]]=sitei[i][1]
    elif(ans[sitei[i][0]]!=sitei[i][1]):
        kano=False

if(ans[0]==0):
    kano=False
if(ans[0]==-1):
    ans[0]==1

if(not kano):
    print(-1)
else:
    kotae=0
    for i in range(m):
        if(ans[i]==-1):
            pass
            #kotae+="0"
        else:
            kotae+=ans[i]*(10**(n-i-1))
    print(kotae)

### FIXED CODE ###

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

ans=[-1]*n

kano=True
for i in range(m):
    if(ans[sitei[i][0]]==-1):
        ans[sitei[i][0]]=sitei[i][1]
    elif(ans[sitei[i][0]]!=sitei[i][1]):
        kano=False

if(n!=1):
    if(ans[0]==0):
        kano=False
    if(ans[0]==-1):
        ans[0]=1


if(not kano):
    print(-1)
else:
    kotae=0
    for i in range(n):
        if(ans[i]==-1):
            pass
            #kotae+="0"
        else:
            kotae+=ans[i]*(10**(n-i-1))
    print(kotae)