Harryxun/stf_run huggingface dataset:
# coding: utf-8
 
a,b=list(map(int,input().split()))
 
mouse_tot = a
mouse_cnt = 1
wa = a-1
 
while True:
    if mouse_tot = b:
        break
    elif mouse_tot < b:
        mouse_tot += wa
        mouse_cnt += 1
 
print(mouse_cnt)

### FIXED CODE ###

# coding: utf-8
 
a,b=list(map(int,input().split()))
 
mouse_tot = 1
mouse_cnt = 0
add_mouse = a-1
 
while mouse_tot <  b:
    mouse_tot += add_mouse
    mouse_cnt += 1
 
if b==0:
    mouse_cnt = 0
 
print(mouse_cnt)
a = 0
while True:
    x = int(input())
    a += 1
    if x == 0: break
    print ("Case {}: {}".format(a. input()))


### FIXED CODE ###

i=1
x = int(input())
while x != 0 :
    print("Case {0}: {1}".format(i, x))
    x = int(input())
    i=i+1
l = list(map(int, input().split()))

cursum = 0

for n in range(1, l[0]+1):
    x = sum(map(int, str(n)))
    if a <= x and x <= b:
        cursum += n

print(cursum)

### FIXED CODE ###

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

cursum = 0

for x in range(1, n+1):
    y = sum(map(int, str(x)))
    if a <= y and y <= b:
        cursum += x

print(cursum)
import sys
import math
import itertools
import collections
import numpy as np

rl = sys.stdin.readline

def a():
    N, M = map(int, rl().split())
    li = [[] for _ in range(N)]
    deg = [0] * N
    for _ in range(M):
        a, b = map(int, rl().split())
        a -= 1
        b -= 1
        li[a].append(b)
        deg[b] = 1
    d = collections.deque([i for i in range(N) if deg[i] == 0])
    dp = [0] * N
    while d:
        i = d.popleft()
        for j in li[i]:
            deg[j] -= 1
            if deg[j] == 0:
                dp[j] = max(dp[j] ,dp[i] + 1)
                d.appendleft(j)
    print(max(dp))
a()




        




### FIXED CODE ###

import sys
import math
import itertools
import collections
import numpy as np

rl = sys.stdin.readline

def a():
    N, M = map(int, rl().split())
    li = [[] for _ in range(N)]
    deg = [0] * N
    for _ in range(M):
        a, b = map(int, rl().split())
        a -= 1
        b -= 1
        li[a].append(b)
        deg[b] += 1
    d = collections.deque([i for i in range(N) if deg[i] == 0])
    dp = [0] * N
    while d:
        i = d.popleft()
        for j in li[i]:
            deg[j] -= 1
            if deg[j] == 0:
                dp[j] = max(dp[j] ,dp[i] + 1)
                d.append(j)
    print(max(dp))
a()
import sys
input=lambda: sys.stdin.readline().rstrip()
n,s=map(int,input().split())
A=[int(i) for i in input().split()]
mod=998244353
B=[[[] for i in range(s+1)] for _ in range(n+1)]
B[0][0].append(0)
ans=0
for i in range(n):
  a=A[i]
  B[i+1][a]+=[i+1]
  for j in range(s+1):
    B[i+1][j]+=B[i][j]
    if j-a>=0 and B[i][j-a]:
      B[i+1][j]+=B[i][j-a]
    
  for aa in B[i+1][s]:
    ans+=aa
  ans%=mod
print(ans)

### FIXED CODE ###

import sys
input=lambda: sys.stdin.readline().rstrip()
n,s=map(int,input().split())
A=[int(i) for i in input().split()]
mod=998244353
B=[[0]*(s+1) for _ in range(n+1)]
ans=0
for i in range(n):
  a=A[i]
  if a<s:
    B[i+1][a]+=i+1
  elif a==s:
    B[i+1][a]+=(i+1)*(n-i)
  for j in range(s+1):
    if j<=s:
      B[i+1][j]+=B[i][j]
    if 0<=j-a and j<s:
      B[i+1][j]+=B[i][j-a]
    if 0<=j-a and j==s:
      B[i+1][j]+=B[i][j-a]*(n-i)
    B[i+1][j]%=mod
print(B[n][s])
def f(a):
	r = []
	for d in range(1,int(a ** 0.5) + 1):
		r.append(d)
        if d * d != a:
	        r.append(a/d)
	return r
a,b = map(int, raw_input().split(' '))
r = 1
for d in f(a):
	if d in f(b):
      	r = max(r, d)#1
print r

   

### FIXED CODE ###

def f(a):
	r = []
	for d in range(1,int(a ** 0.5) + 1):
		if a % d == 0:
			r.append(d)	
			if d * d != a: r.append(a/d)
	return r if r else [1]
a,b,k = map(int, raw_input().split(' '))
r = []
for d in f(a):
	if d in f(b):
		r.append(d)

r.sort()

print r[-k]
def return_sorted_string(string):
    lst=list(map(ord,list(string)))
    lst.sort()
    lst=list(map(chr,lst))
    string="".join(lst)
    return string
    



n = int(input())
strings=[input() for i in range(n)]
dic={}
for i in range(n):
    string=return_sorted_string(strings[i])
    if string in dic:
        dic[string]+=1
    else:
        dic[string]=1

count=0        

for i in dic.values():
    count += i*(i-1)/2


print(int(count))

### FIXED CODE ###

a,b=list(map(int,input().split()))
print(max(a+b,a-b,a*b))
def popcnt_int(n): # n:int
    return bin(n).count('1')

def popcnt_bin(s): # s:str
    return s.count('1')

def poptimes(n, cnt=1): #:int
    if n==0:
        return cnt
    else:
        n %= popcnt_int(n)
        cnt += 1
        return poptimes(n, cnt)

n = int(input())
s = input()

s_int = int(s,2)
pc = popcnt_bin(s)
pc_plus = pc+1
pc_minus = pc-1
#print(n,s,s_int,pc,pc_plus,pc_minus)

l_plus = [2**(n-i-1) % (pc_plus) for i in range(n)]
l_minus = [2**(n-i-1) % (pc_minus) for i in range(n)]
#print(l_plus)
#print(l_minus)

for i in range(n):
    if s[i] == '1':
        if pc != 1:
            tmp = (s_int - l_minus[i]) % (pc_minus)
            print(poptimes(tmp))
        else:
            print(0)
            continue
    
    else:
        tmp = (s_int + l_plus[i]) % (pc_plus)
        print(poptimes(tmp))


### FIXED CODE ###

def popcnt_int(n): # n:int
    return bin(n).count('1')

def popcnt_bin(s): # s:str
    return s.count('1')

def poptimes(n, cnt=1): #:int
    if n==0:
        return cnt
    else:
        n %= popcnt_int(n)
        cnt += 1
        return poptimes(n, cnt)

n = int(input())
s = input()

s_int = int(s,2)
pc = popcnt_bin(s)
pc_plus = s_int % (pc+1)
if  pc != 1:
    pc_minus = s_int % (pc-1)
#print(n,s,s_int,pc,pc_plus,pc_minus)

for i in range(n):
    if s[i] == '1':
        if pc != 1:
            tmp = pc_minus - pow(2, n-i-1, pc-1)
            print(poptimes(tmp % (pc-1)))
        else:
            print(0)
            continue
    
    else:
        tmp = pc_plus + pow(2, n-i-1, pc+1)
        print(poptimes(tmp % (pc+1)))
S = input()
N = len(S)
MOD = 10 ** 9 + 7

dp = [0, 0, 0, 0]
dp[0] = 1

for s in S:
    factor = 3 if s == '?' else 1
    for j, c in zip([2, 1, 0], 'CBA'):
        dp[j + 1] = dp[j + 1] * factor % MODE
        if s == c or s == '?':
            dp[j + 1] += dp[j]
    if s == '?':
        dp[0] = dp[0] % MOD

ans = dp[-1] % MOD

print(ans)

### FIXED CODE ###

S = input()
N = len(S)
MOD = 10 ** 9 + 7

dp = [0, 0, 0, 0]
dp[0] = 1

for s in S:
    factor = 3 if s == '?' else 1
    for j, c in zip([2, 1, 0], 'CBA'):
        dp[j + 1] = dp[j + 1] * factor % MOD
        if s == c or s == '?':
            dp[j + 1] += dp[j]
    if s == '?':
        dp[0] = (dp[0] * 3) % MOD

ans = dp[-1] % MOD

print(ans)
N = int(input())
    A_list = input().split()
    A_list_i = [int(s, 0) for s in A_list]
    max_gcd = 1
    min_gcd = [10000000000, -1]
    for i in range(N-1):
        for j in range(i+1, N):
            if A_list_i[i] == A_list_i[j]:
                temp = A_list_i[i]
            elif A_list_i[i] > A_list_i[j]:
                temp = A_list_i[i] % A_list_i[j]
            else:
                temp = A_list_i[j] % A_list_i[i]
            if temp > max_gcd:
                max_gcd = temp
            if temp < min_gcd[0]:
                min_gcd[0] = temp
                if A_list_i[i] > A_list_i[j]:
                    min_gcd[1] = i
                else:
                    min_gcd[1] = j
    A_list_i[min_gcd[1]] = max_gcd
    temp = 0
    max_gcd = 1
    for i in range(N-1):
        for j in range(i+1, N):
            if A_list_i[i] == A_list_i[j]:
                temp = A_list_i[i]
            elif A_list_i[i] > A_list_i[j]:
                temp = A_list_i[i] % A_list_i[j]
            else:
                temp = A_list_i[j] % A_list_i[i]
            if temp > max_gcd:
                max_gcd = temp            
    print('%d' % max_gcd)

### FIXED CODE ###

raw_input = input()
a, b, t = map(int, raw_input.split())
counter = (t+0.5)//a #クッキを焼く回数
number = b * counter #枚数
print('%d' % number)
a, b, m = map(int, input().split())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
crr = [[0] * b for _ in range(a)]
xycs = [tuple(map(int, input().split())) for _ in range(m)]
ans = min(arr) + min(brr)

for elem in xycs:
    x = elem[0]
    y = elem[1]
    c = elem[2]
    ans = min(arr[x - 1] + arr[y - 1] - c, ans)

print(ans)


### FIXED CODE ###

a, b, m = map(int, input().split())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
xycs = [tuple(map(int, input().split())) for _ in range(m)]
ans = min(arr) + min(brr)

for elem in xycs:
    x = elem[0]
    y = elem[1]
    c = elem[2]
    ans = min((arr[x - 1] + brr[y - 1] - c), ans)

print(ans)
S = input()

ans = 0
if S ='RRR': ans = 3
else:
  if ('RR' in S) ans = 2
  else:
    if('R' in S) ans = 1
    else: ans = 0
    
print(ans)

### FIXED CODE ###

S = input()
 
ans = 0
if S == 'RRR': ans = 3
else:
  if ('RR' in S): ans = 2
  else:
    if('R' in S): ans = 1
    else: ans = 0
 
print(ans)
n=int(input())
h = [input() for d in range (n)]
alphabet=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
list=[]


for k in range(26):
    for i in range (n):
         m=50
         x =h[i].count(alphabet[k])
         m =min(x,m)
    list.append(alphabet[k]*m)

print('',join(list))



### FIXED CODE ###

n=int(input())
h = [input() for d in range (n)]
alphabet=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
list=[]


for k in range(26):
    m=50
    for i in range (n):
         x =h[i].count(alphabet[k])
         m =min(x,m)
    list.append(alphabet[k]*m)

print(''.join(list))
N = int(input())
for i in range(9):
  for j in range(9):
    if (i+!)*(j+1) == N:
      print("Yes")
      exit()
print("No")

### FIXED CODE ###

N = int(input())
l = []
for i in range(1,10):
  for j in range(1,10):
    l.append(i*j)
    
if N in l:
  print("Yes")
  exit()
else:
  print("No")
  exit()
s = input()
 
ss = ""
for i in s:
  if s == "1"
  	ss += "9"	
  else:
    ss += "1"
    
print(ss)

### FIXED CODE ###

s = input()
 
ss = ""
for i in s:
  if i == "1":
  	ss += "9"	
  else:
    ss += "1"
    
print(ss)
n, x, m = map(int, input().split())

def main(a):
    if a == 1:
        return x
    if a >= 2:
        return (main(a-1)**2) % m

ans = 0
for i in range(1, n+1):
    ans += main(i)
print(ans)

### FIXED CODE ###

import sys

input = sys.stdin.readline

N, X, M = map(int, input().split())
LIST = [X]
SET = {X}

a = X

while True:
    if a * a % M in SET:
        break
    else:
        a = a * a % M
        LIST.append(a)
        SET.add(a)

# 繰り返しがaから始まる
# SETには順番が記録されていないのでLISTを使う
start = LIST.index(a * a % M)
LEN = len(LIST)

if N <= LEN:
    print(sum(LIST[:N]))
else:
    LoopTimes, Excess = divmod(N-LEN, LEN-start)
    LoopSum = sum(LIST[start:]) * LoopTimes
    ExSum = sum(LIST[start:start+Excess])
    print(sum(LIST[:]) + LoopSum + ExSum)
from fractions import gcd
import sys

input = sys.stdin.buffer.readline
mod = 10 ** 9 + 7


def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0


def modinv(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        raise Exception("modular inverse does not exist")
    else:
        return x % m


n = int(input())
if n == 1:
    print(1)
    exit()
A = list(map(int, input().split()))
lcm = A[0]
for i in range(n):
    g = gcd(lcm, A[i])
    lcm = lcm * A[i] // g
ans = 0
for i in range(n):
    gyaku = modinv(A[i])
    ans += lcm * gyaku
    ans %= mod
print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline
from fractions import gcd
n=int(input())
A=list(map(int,input().split()))
mod=10**9+7
def gyaku(a):
    return pow(a,mod-2,mod)
if n==1:
    print(1)
else:
    gya=[0]*(n)
    g=A[0]
    l=A[0]
    gya[0]=gyaku(A[0])
    for i in range(n-1):
        g=gcd(l,A[i+1])
        l*=(A[i+1]//g)
        gya[i+1]=gyaku(A[i+1])
    ans=0
    for i in range(n):
        ans+=l*gya[i]
        ans%=mod
    print(ans)
N,A,B=map(int,input().split())
S=list(map(input().split()))
sin=0
cos=0
for i in range(S)
	if S.pop(i)='a'or'b':
    sin+=1
    if S.pop(i)='b':
    cos+=1
    print("Yes" if S.pop(i)='a' and sin<A+B:
"Yes" elif S.pop(i)='b' and B<=cos and sin<A+B:
    else "No")
    
    


### FIXED CODE ###

N,h,u=map(int,input().split())
S = input()
kaigai=0
goukei=0
for i in range(0,N):
  if S[i]=='a' and goukei<h+u:
    print("Yes")
    goukei+=1
  elif S[i]=='b'and goukei<h+u and kaigai<u:
    print("Yes")
    goukei+=1
    kaigai+=1
  else:
    print("No")
def solve(s):
    if s[0]!='A':
        return 'WA'
    if s[3:len(s)-1].count('C')!=1:
        return 'WA'
    s=s.split('A').split('C')
    if not s.islower():
        return 'WA'
    return 'AC'
  
s=input()
print(solve(s))
    	


### FIXED CODE ###

def solve(s):
    if s[0]!='A':
        return 'WA'
    if s[2:len(s)-1].count('C')!=1:
        return 'WA'
    s=str(s.split('A'))
    s=str(s.split('C'))
    if not s.islower():
        return 'WA'
    return 'AC'

s=input()
print(solve(s))
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n=I()
lis=LI()
count=0
while sum(lis)>0:
    i=0
    while i<n:
        if lis[i]>0:
            lis[i]-=1
            state="water"
            #print(1)
        elif lis[i]==0 and state=="water":
            count+=1
            state=""
            #print(2)
        if i==n-1 and state=="water":
            count+=1
            state=""
            #print(3)
        i+=1
print(count)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n=I()
lis=LI()
count=0
while sum(lis)>0:
    i=0
    state=""
    while i<n:
        if lis[i]>0:
            lis[i]-=1
            state="water"
            #print(1)
        elif lis[i]==0 and state=="water":
            count+=1
            state=""
            #print(2)
        if i==n-1 and state=="water":
            count+=1
            state=""
            #print(3)
        i+=1
print(count)
a,b = map(int,input())
if (a<=8 and b<=8):
  print("Yay!")
else:
  print(":(")

### FIXED CODE ###

a,b = map(int,input().split())
if (a<=8 and b<=8):
  print("Yay!")
else:
  print(":(")
s1, s2, s3 = map( str, input().split() )
print( s1[0].upper + s2[0].upper + s3[0].upper ) 

### FIXED CODE ###

s1, s2, s3 = map( str, input().split() )
print( s1[0].upper() + s2[0].upper() + s3[0].upper() )
#23:39
a = map(int,input().split())
print( sum(a) - max(a) )

### FIXED CODE ###

A = list(map(int,input().split()))
print(sum(A)-max(A))
S = input()
C = 10**9+7


def answer(a):
    if a == '0' or a == '':
        return 1
    if a == '1':
        return 3
    if a[0] == '0':
        return answer(a[1:])
    else:
        b = a[1:]
        return (pow(3, (len(a)-1), C)+2*answer(b)) % C


print(answer(S))

### FIXED CODE ###

S = input()
C = 10**9+7
T = S[::-1]
N = len(S)
dp = [0]*N
dp[0] = 1+2*(int(T[0]))

for i in range(1, N):
    if T[i] == '0':
        dp[i] = dp[i-1]
    else:
        dp[i] = (pow(3, i, C)+2*dp[i-1]) % C
print(dp[-1])
n = []
j = True

N, M = list(map(int, input().split()))
for i in range(N):
    n.append('W')

for i in range(M):
    s, c = list(map(int, input().split()))
    if n[s-1] == "W":
        n[s-1] = c
    elif n[s-1] == c:
        pass
    else:
        print(-1)
        j = False
        
if j == True:
    for i in range(3):
        if n[i] =="W":
            n[i] = 0
    if n[0] == 0:
        print(-1)
    else:
        print(''.join(map(str,n)))

### FIXED CODE ###

n = []

N, M = list(map(int, input().split()))
for i in range(N):
    n.append('W')

for i in range(M):
    s, c = list(map(int, input().split()))
    s -= 1
    if n[s] == "W":
        n[s] = c
    elif n[s] == c:
        pass
    else:
        print(-1)
        exit()
        
if N != 1:
    if n[0] == 0:
        print(-1)
        exit()
    
    if n[0] == "W":
        n[0] = 1
        
    for i in range(N):
        if n[i] =="W":
            n[i] = 0

else:
    if n[0] == "W":
        n[0] = 0
        
print(''.join(map(str,n)))
s = input()
s[5] = " "
s[:5] = " "
print(s)

### FIXED CODE ###

s = input()
k = []
ans = ""
for i in range(19):
  k.append(s[i])
for i in range(19):
  if k[i] == ",":
    k[i] = " "
  ans += k[i]
print(ans)
def dynamic(n):
    if n == 0 or n == 1:
        return 1
    if F[n] != 0:
        return F[n]
    F[n] = dynamic(n - 1) + dynamic(n - 2)
    return F[n]

if __name__ == '__main__':
    n = int(raw_input())
    print(dynamic(n))

### FIXED CODE ###

N = 44
F = [0]*(N+1)

def dynamic(n):
    if n == 0 or n == 1:
        return 1
    if F[n] != 0:
        return F[n]
    F[n] = dynamic(n - 1) + dynamic(n - 2)
    return F[n]

if __name__ == '__main__':
    n = int(raw_input())
    print(dynamic(n))
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
list1 = []
ame = A[0]
for i in range(N-1):
  list1.append(sum(A[:i+1])+sum(B[i:]))
  
if list1 = []:
  print(A[0]+b[0])
else:
  print(max(list1))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
list1 = []
ame = A[0]
for i in range(N-1):
  list1.append(sum(A[:i+1])+sum(B[i:]))
  
if list1 == []:
  print(A[0]+B[0])
else:
  print(max(list1))
n = input()
s = list(map(int, input().split()))
c = 0
while True:
        exist = False
        #print(s)
        for i in range(len(s)):
                #print(i)
                if s[i]%2 != 0:
                        exist = True

        if exist:
                print(c)
                break
        for i in range(len(s)):
                s[i] = s[i]/2
        c += 1

### FIXED CODE ###

s = input()
c = 0
if s[0] == "1": c += 1
if s[1] == "1": c += 1
if s[2] == "1": c += 1
print(c)
a, b = map(int, input().split())
def gcd(x, y):
    if y == 0:
        return x
    else:
        gcd(y, x%y)
n = gcd(a, b)
ndiv = n
i = 2
primecount = 0
divisor = False
while i*i <= n:
    while ndiv%i == 0:
        ndiv = ndiv//i
        divisor = True
    if divisor:
        primecount += 1
        divisor = False
    i += 1

print(primecount+1)


### FIXED CODE ###

a, b = map(int, input().split())
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x%y)
n = gcd(a, b)
ndiv = n
if n == 1:
    print(1)
else:
    i = 1
    primecount = 0
    divisor = False
    while True:
        i += 1
        while ndiv%i == 0:
            ndiv = ndiv//i
            divisor = True
        if divisor:
            primecount += 1
            divisor = False
            if ndiv == 1:
                break
        if ndiv != 1 and i*i > n:
            primecount += 1
            break
    print(primecount+1)
while x>0:
    if (k == 1):
        rlist = [0]
        break
    rlist.append(abs(x-k))
    x = abs(x-k)
    min_n = min(rlist)
    if (min_n == abs(x-k)):break
    if (min_n == 0):break
    if(len(set(rlist)) != len(rlist)):
        break

print(min(rlist))

### FIXED CODE ###

n, k = map(int, input().split()) 
t = n % k
if (k-t > t):
    print(t)
else:
    print(k-t)
#include <stdio.h>

int main() {
    int N;

    scanf("%d", &N);

    if ( (N % 10 == 9) || (N / 10 == 9) ) {
        puts("Yes");
    }
    else {
        puts("No");
    }

    return 0;
}

### FIXED CODE ###

N = int(raw_input())

print "Yes" if (N % 10 == 9) or (N / 10 == 9) else "No"
n,m = [int(x) for x in input().split()]
sc = {}
out = False
for _ in range(m):
    s,c = [x for x in input().split()]
    if s in sc.keys():
        if sc[s] != c:
            print("-1")
            out = True
        else:
            sc[s] = c
    else:
        sc[s] = c
        

if not out:
    if n == 1:
        print(sc["1"])
    elif n == 2:
        if "1" in sc.keys():
            if sc["1"] != "0":
                if "2" in sc.keys():
                    print(sc["1"],sc["2"],sep="")
                else:
                    sc["2"] = "0"
                    print(sc["1"],sc["2"],sep="")
            else:
                print("-1")
        else:
            sc["1"] = "1"
            print(sc["1"],sc["2"],sep="")
    elif n == 3:
        if "1" in sc.keys():
            if sc["1"] != "0":
                if "2" in sc.keys():
                    if "2" in sc.keys():
                        print(sc["1"],sc["2"],sc["3"],sep="")
                    else:
                        sc["3"] = "0"
                        print(sc["1"],sc["2"],sc["3"],sep="")
                else:
                    sc["2"] = "0"
                    if "3" in sc.keys():
                        print(sc["1"],sc["2"],sc["3"],sep="")
                    else:
                        sc["3"] = "0"
                        print(sc["1"],sc["2"],sc["3"],sep="")
            else:
                print("-1")
        else:
            sc["1"] = "1"
            if not "2" in sc.keys():
                sc["2"] = "0"
            if not "3" in sc.keys():
                sc["3"] = "0"
            print(sc["1"],sc["2"],sc["3"],sep="")

### FIXED CODE ###

n,m = [int(x) for x in input().split()]
sc = {}
out = False
for _ in range(m):
    s,c = [x for x in input().split()]
    if s in sc.keys():
        if sc[s] != c:
            print("-1")
            out = True
        else:
            sc[s] = c
    else:
        sc[s] = c
        

if not out:
    if n == 1:
        if not "1" in sc.keys():
            sc["1"] = "0"
        print(sc["1"])
    elif n == 2:
        if not "1" in sc.keys():
            sc["1"] = "1"
            if not "2" in sc.keys():
                sc["2"] = "0"
            print(sc["1"],sc["2"],sep="")
        else:
            if sc["1"] == "0":
                print("-1")
            else:
                if not "2" in sc.keys():
                    sc["2"] = "0"
                print(sc["1"],sc["2"],sep="")
    elif n == 3:
        if not "1" in sc.keys():
            sc["1"] = "1"
            if not "2" in sc.keys():
                sc["2"] = "0"
            if not "3" in sc.keys():
                sc["3"] = "0"
            print(sc["1"],sc["2"],sc["3"],sep="")
        else:
            if sc["1"] == "0":
                print("-1")
            else:
                if not "2" in sc.keys():
                    sc["2"] = "0"
                if not "3" in sc.keys():
                    sc["3"] = "0"
                print(sc["1"],sc["2"],sc["3"],sep="")