Harryxun/stf_run huggingface dataset:
while True:
    L=input()
    if L=0:break
    flag=True
    for i in range(1,13):
        M,N=map(int,raw_input().split())
        L-=(M-N)
        if L<=0 and flag:
            print i
            flag=False
    else:
        print "NA"

### FIXED CODE ###

while True:
    L=input()
    if L==0:break
    T=[]
    for i in range(1,13):
        M,N=map(int,raw_input().split())
        T.append(M-N)
    for i in range(1,13):
        L-=T[i-1]
        if L<=0:
            print i
            break
    else:
        print "NA"
a, b, c = map(int, input().split())
for i in range(i, b+1):
  if a*i%b == c:
    print('YES')
    break
else:
  print('NO')

### FIXED CODE ###

a, b, c = map(int, input().split())
for i in range(1, b+1):
  if a*i%b == c:
    print('YES')
    break
else:
  print('NO')
N = int(input())

if N == 1:
    print("Hello World")

elif N == 2:
    A = int(input())
    b = int(input())
    print(A+B)

### FIXED CODE ###

N = int(input())

if N == 1:
    print("Hello World")

elif N == 2:
    A = int(input())
    B = int(input())
    print(A+B)
# a = input()
# b = input()
a,b = input().split() 

if(a == b[::-1] and b == a[::-1]):
    print('YES')
else:
    print('NO')

### FIXED CODE ###

a = input()
b = input()
if(a == b[::-1] and b == a[::-1]):
    print('YES')
else:
    print('NO')
N, X = map(int, input().split())
L = list(map(int, input().split()))
B=sum(L)
count=1
if X>=B:
  print(len(L)+1)
else:
  i=0
  H=0
  while H<=X:
    H=H+L[i]
    i=i+1
  print(i)

### FIXED CODE ###

N,L=map(int, input().split())
if N+L-1<=0:
  print(int(L*(N-1)+N*(N-1)/2-N+1))
elif L>=0:
  print(int(L*(N-1)+N*(N+1)/2-1-N+1))
else :
  print(int(L*N+N*(N+1)/2-N))
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
i,j,k=0
ans+=1
while i<n and j<n and k<n:
  while j<n and a[i]>=b[j]:
    j+=1
  while k<n and b[j]>=c[k]:
    k+=1
  ans+=1
  i+=1
  j+=1
  k+=1
print(ans)

### FIXED CODE ###

import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
ans=0
for i in range(n):
  j=bisect.bisect_left(a,b[i])
  k=n-bisect.bisect_right(c,b[i])
  ans+=j*k
print(ans)
import itertools

def c165(n, m, q, adli):

    ans = 0
    li = list(itertools.combinations_with_replacement(range(1,M+1), n))
    for i in li:
        count = 0
        for a, b, c, d in adli:
            if i[b-1] - i[a-1] == c:
                count += d
        ans = max(ans, count)

    return ans

def main():
    n, m, q = map(int, input().split())
    adli = [list(map(int, input().split()))for i in range(q)]
    print(c165(n, m, q, adli))

if __name__ == '__main__':
    main()

### FIXED CODE ###

import itertools

def c165(n, m, q, adli):

    ans = 0
    li = list(itertools.combinations_with_replacement(range(1,m+1), n))
    for i in li:
        count = 0
        for a, b, c, d in adli:
            if i[b-1] - i[a-1] == c:
                count += d
        ans = max(ans, count)

    return ans

def main():
    n, m, q = map(int, input().split())
    adli = [list(map(int, input().split()))for i in range(q)]
    print(c165(n, m, q, adli))

if __name__ == '__main__':
    main()
n,m = map(int,input().split())
if m ==0:
    print(0,0)
    exit()
p = [0] * m 
s = [0] * m
w_count = 0
a_count = 0

for i in range(m):
    p[i],s[i] = input().split()

p = sorted(set(p))
i = int(p[0])
j = 0

while i != int(p[-1]) + 1:
    if p[j] == i and s[j] == 'WA':
        w_count += 1
    elif p[j] == i and s[j] == 'AC':
        a_count += 1
        i += 1
    j += 1

print(a_count,w_count)

        


### FIXED CODE ###

n, m = map(int,input().split())
a = [input().split() for i in range(m)]
p = [int(i[0]) for i in a]
q = [j[1] for j in a]

ac = 0
wa = 0
wa_c = [0] * n
ac_c = [False] * n

for t in range(m):
    if ac_c[p[t]-1]:
        continue
    if q[t] == 'AC':
        ac += 1
        ac_c[p[t]-1] = True
        wa += wa_c[p[t]-1]
    else:
        wa_c[p[t]-1] += 1
print(ac,wa)
W,H,x,y,r = int(input().splite())
if x+r < W and y+r < H :
	print('Yes')
else:
	print('No')


### FIXED CODE ###

W,H,x,y,r = map(int,input().split())
ok = 1
if x < r or W - x <r :
 ok = False
if y < r or H - y < r :
 ok = False
print('Yes') if ok else print('No')
N,k = map(int,input().split())
S = input()
lenth = 0
AllLen =[]
preS0,preS1 = S.split('1'),S.split('0')
S0 = [i for i in preS0 if i != '']
S1 = [i for i in preS1 if i != '']
num0 = k
if len(S0) <= k:
	print(len(S))
	exit() 
if S[0] == '0':
	J = k
else:J = k + 1
FirstLen = sum([len(S0[i]) for i in range(k)]) + sum([len(S1[j]) for j in range(J)])
AllLen.append(FirstLen)
CheckLen = FirstLen
if S[0] == '1' and S[-1] == '1':
    for i in range(len(S0) - k):
	    CheckLen = CheckLen - len(S0[i]) - len(S1[i]) + len(S0[i + k]) + len(S1[i + k + 1])
	    AllLen.append(CheckLen)
if S[0] == '0' and S[-1] == '1':
	CheckLen = CheckLen - len(S0[0]) + len(S0[k]) + len(S1[k])
	AllLen.append(CheckLen)
	for i in range(len(S0) - k - 1):
		CheckLen = CheckLen - len(S0[i + 1]) - len(S1[i + 1]) + len(S0[i + k + 1]) + len(S1[i + k + 2])
		AllLen.append(CheckLen)
if S[0] == '1' and S[-1] == '0':
	for i in range(len(S0) - k - 1):
		CheckLen = CheckLen - len(S0[i]) - len(S1[i]) + len(S0[i + k]) + len(S1[i + k + 1])
		AllLen.append(CheckLen)
	CheckLen = CheckLen - len(S0[len(S0) - k - 1]) - len(S1[len(S0) - k - 1]) + len(S0[len(S0) - 1])
	AllLen.append(CheckLen)
if S[0] == '0' and S[-1] == '0':
	if len(S1) == 1:
		print(len(max(S0)) + len(S1[0]))
		exit()
	CheckLen = CheckLen - len(S0[0]) + len(S0[k]) + len(S1[k])
	AllLen.append(CheckLen)
	for i in range(len(S0) - k - 2):
		CheckLen = CheckLen - len(S0[i + 1]) - len(S1[i + 1]) + len(S0[i + k + 1]) + len(S1[i + k + 2])
		AllLen.append(CheckLen)
	CheckLen = CheckLen - len(S0[len(S0) - k - 1]) - len(S1[len(S0) - k - 1]) + len(S0[len(S0) - 1])
	AllLen.append(CheckLen)
print(max(AllLen))

### FIXED CODE ###

n,k = map(int,input().split())
s = input()
befores = '1'
cnt = 0
snum = []
for S in s:
	if S == befores:
		cnt += 1
	else:
		snum.append(cnt)
		cnt = 1
		befores = S
snum.append(cnt)
if s[-1] == '0':
    snum.append(0)
kazu = sum(snum[0:k * 2  + 1])
kaisuu = sum(snum[0:k * 2  + 1])
time = int((len(snum) - k * 2 - 1) / 2 )
one = 0
zero = 1
k = k * 2
for i in range(time):
	kazu = kazu - snum[one] - snum[zero] + snum[one + k + 2] + snum[zero + k]
	kaisuu = max(kaisuu,kazu)
	one += 2
	zero += 2
print(kaisuu)
import bisect
from itertools import *
n=range(49994);a=list(n)
for i in range(2,224):a[i*2::i]=[0]*len(a[i*2::i])
p=list(compress(n,a))
for x in iter(input,'0'):
 x=int(x)
 y=bisect.bisect(p,x//2)
 if x%2:print(sum(1 for c in p[1:y]if 2+c==x))
 elif x-4:print(sum(1 for c in p[1:y]if a[x-c]))
 else:print(1)


### FIXED CODE ###

import bisect,sys
from itertools import *
n=range(50001);a=list(n);a[1]=0
for i in range(2,224):a[i*2::i]=[0]*len(a[i*2::i])
p=list(compress(n,a))
for x in map(int,sys.stdin):
 if x:print(len([1 for d in p[:bisect.bisect(p,x//2)]if a[x-d]]))
File Edit Options Buffers Tools Python Help                                                                                                                                              
# -*- coding: utf-8 -*-                                                                                                                                                                  

import sys

b=input()
if b=='A':
    print('T')
elif b=='T':
    print('A')
elif b=='C':
    print('G')
elif b=='G':
    print('C')
else :
    sys.exit()


### FIXED CODE ###

import sys

b=input()
if b=='A':
    print('T')
elif b=='T':
    print('A')
elif b=='C':
    print('G')
elif b=='G':
    print('C')
else :
    sys.exit()
#!/usr/bin/env python3
inf = float('inf')

def dfs(s):
    for t, d in G[s]:
        if x[t] == inf:
            x[t] = x[s] + d
            dfs(t)
        else:
            if x[t] - x[s] != d:
                return False
    return True

N, M = map(int, input().split())
x = [inf] * N
G = [[] for _ in range(N)]
ans = True
for i in range(M):
    L, R, D = map(int, input().split())
    L -= 1
    R -= 1
    G[L].append([R, D])
    G[R].append([L, -D])
for i in range(N):
    if x[i] == inf:
        x[i] = 0
        if not dfs(i):
            ans = False
print(('No', 'Yes')[ans])


### FIXED CODE ###

#!/usr/bin/env python3
import sys
sys.setrecursionlimit(200002)

def dfs(s):
    for t, d in G[s]:
        if x[t] is None:
            x[t] = x[s] + d
            if not dfs(t):
                return False
        else:
            if x[t] - x[s] != d:
                return False
    return True

N, M = map(int, input().split())
x = [None] * N
G = [[] for _ in range(N)]
for i in range(M):
    L, R, D = map(int, input().split())
    L -= 1
    R -= 1
    G[L].append([R, D])
    G[R].append([L, -D])
ans = True
for i in range(N):
    if x[i] is None:
        x[i] = 0
        if not dfs(i):
            ans = False
print(('No', 'Yes')[ans])
ss=input().split()
a,b=list(map(int,input()))
s=input()
if s==ss[0]: print(a-1,b)
elif s==ss[1]:print(a,b-1)

### FIXED CODE ###

sp=input().split()
A,B=list(map(int,input().split()))
s=input()
if sp[0]==s:print(A-1,B)
elif sp[1]==s:print(A,B-1)
a=[]
for i in range(3):
    a.append(list(map(int,input().split())))
n=input()
for i in range(n):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if a[i][j]==b:
                a[i][j]=0

ans=0
for l in range(3):
    if a[l][0]==0 and a[l][1]==0 and a[l][2]==0:
        ans=1
        break
    elif a[0][l]==0 and a[1][l==0 and a[2][l]==:
        ans=1
        break

if ans==1:
    print("Yes")
elif a[1][1]==0 and a[2][2]==0 and a[0][0]==0:
    print("Yes")
elif a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

a=[]
for i in range(3):
    a.append(list(map(int,input().split())))
n=int(input())
for i in range(n):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if a[k][j]==b:
                a[k][j]=0

ans=0
for l in range(3):
    if a[l][0]==0 and a[l][1]==0 and a[l][2]==0:
        ans=1
        break
    elif a[0][l]==0 and a[1][l]==0 and a[2][l]==0:
        ans=1
        break




if ans==1:
    print("Yes")
elif a[1][1]==0 and a[2][2]==0 and a[0][0]==0:
    print("Yes")
elif a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
    print("Yes")
else:
    print("No")
X,Y = map(int,input().split())
dp = [[0]*(X+10) for _ in range(Y+10)]
dp[2][1] = 1
dp[1][2] = 1

for i in range(2,X+1):
    for j in range(max(2,i//2),min(Y+1,i//2+1)):
        dp[i][j] = (dp[i-2][j-1] + dp[i-1][j-2]) % (10**9+7)

print(dp[X][Y])

### FIXED CODE ###

X,Y = map(int,input().split())

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def combi(n,r,mod=10**9+7):
    fac = [0]*(n+1)
    fac[0] = 1
    fac[1] = 1
    for i in range(2,n+1):
        fac[i] = fac[i-1] * i % mod
    return( ( fac[n] * modinv(fac[r]) )%mod * modinv(fac[n-r]) % mod)

if (X+Y) % 3 != 0 or X > 2*Y or Y > 2*X:
    print(0)
else:
    n = X - (X + Y)//3
    m = (X + Y)//3 - n
    print(combi(n+m,m))
MAX = int(2e5)+1


n = int(input())
lis = list(map(int,input().split()))
lis2 = [0]*MAX
# lis.sort()
# m = max(lis)
ans = 0
for num in lis:
    lis2[num] += 1

for num in lis:
    for i in range(num*2, MAX+1, num):
        if lis2[i] > 0:
            lis2[i] += 1

print(len([i for i in lis if lis2[i] == 1]))

### FIXED CODE ###

# MAX = int(1e6)+2


n = int(input())
lis = list(map(int,input().split()))
lis.sort()
MAX = lis[-1]
lis2 = [0]*(MAX+1)
# lis.sort()
# m = max(lis)
ans = 0

for num in lis:
    for i in range(num, MAX+1, num):
            lis2[i] += 1

for j in set(lis):
    if lis2[j] == 1:
        ans += 1
print(ans)
N,Y=map(int,input().split())
answer=[-1, -1, -1]
for i in range(N+1):
  for j in range(N-i+1):
    k= N-i-j
    a=10000*i+5000*j+1000*k
        if Y==a:
            answer=[i,j,k]
            break
print(*answer)

### FIXED CODE ###

N,Y=map(int,input().split())
answer=[-1, -1, -1]
for i in range(N+1):
  for j in range(N-i+1):
    k= N-i-j
    a=10000*i+5000*j+1000*k
    if Y==a:
      answer=[i,j,k]
      break
print(*answer)
n = int(input())
s = list(input())
while s[-1] == "#":
    s.pop()
s = "".join(s)
n = len(s)
data = []
ind = []
cnt = 0
ans = 0
for i in range(n):
    if s[i] == "#":
        cnt += 1
        ind.append(i)
    data.append(cnt)
if not ind:
    print(0)
    exit()
for i in ind:
    m = data[-1]-data[i]+1
    l = n-m-i
    if l > m:
        ans += 1
    else:
        print(ans+l)
        break
else:
    print(ans)

### FIXED CODE ###

n = int(input())
s = input()
rw = s.count(".")
lb = 0
M = rw+lb
for i in range(n):
    if s[i] =="#":
        lb += 1
    else:
        rw -= 1
    M = min(M,rw+lb)
print(M)
import math
import random

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

def quick(x):
  pri = math.floor(A * x / B)
  lat = A * math.floor(x / B)
  return math.floor(pri - lat)

max = quick(N)
for i in range(1000000):
  ran = math.floor(random.uniform(0, N))
  tem = quick(ran)
  if(max < tem):
    max = tem

print(max)


### FIXED CODE ###

N = int(input())
mi,ma = map(int,input().split())

flag = 0
for i in range(mi,ma+1):
  if(i % N == 0):
    flag = 1
    break
if(flag == 1):
  print('OK')
else:
  print('NG')
H, W = map(int, input().split())
S = []
for i in range(H):
    S.append(list(input()))
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

for i in range(H):
  for j in range(W):
    if s[i][j] == '#':
      continue
    cnt = 0
    for n in range(8):
      ni = i + dx[n]
      nj = j + dy[n]
      if ni < 0 or H <= ni or nj < 0 or W <= nj:
        continue
      if S[ni][nj] == '#':
        cnt += 1
    S[i][j] = str(cnt)


    
for i in range(H):
    print("".join(S[i]))

### FIXED CODE ###

H, W = map(int, input().split())
S = []
for i in range(H):
    S.append(list(input()))
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

for i in range(H):
  for j in range(W):
    if S[i][j] == '#':
      continue
    cnt = 0
    for n in range(8):
      ni = i + dx[n]
      nj = j + dy[n]
      if ni < 0 or H <= ni or nj < 0 or W <= nj:
        continue
      if S[ni][nj] == '#':
        cnt += 1
    S[i][j] = str(cnt)


    
for i in range(H):
    print("".join(S[i]))
n = int(input())

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

d.sort()

m = 0

for a in range(n-2):
	for b in range(a+1,n-1):
		for c in range(b+1,n):
			if d[c]<d[b]+d[a]:
				m += 1
				if d[c]==d[a]:
                  m -= 1
			else:
				break

print(m)

### FIXED CODE ###

import bisect

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

m = 0

for a in range(n-2):
	for b in range(a+1,n-1):
		m+=bisect.bisect_left(d,d[a]+d[b])-1-b

print(m)
a, b = int(input())
if a == 1:
    a = 14
elif b == 1:
    b = 14

if a > b:
    print("Alice")
elif a < b:
    print("Bob")
else:
    print("Draw")

### FIXED CODE ###

a, b = map(int, input().split())
if a == 1:
    a = 14
if b == 1:
    b = 14

if a > b:
    print("Alice")
elif a < b:
    print("Bob")
else:
    print("Draw")
def main():
    h, w, m = map(int, input().split())
    L = [list(map(int,input().split())) for _ in range(m)]
    table = [[0] * w for _ in range(h)]
    for a, b in L:
        table[a-1][b-1] = 1
    col = [0] * w
    row = [0] * h
    for i in range(w):
        col[i] = sum([T[i] for T in table])
    for j in range(h):
        row[j] = sum(table[j])
    mxCol = [i for i, v in enumerate(col) if v == max(col)]
    mxRow = [i for i, v in enumerate(row) if v == max(row)]
    ans = max(col) + max(row)
    for c in mxCol:
        for r in mxRow:
            if not table[r][c]:
                print(ans)
                return
    print(ans-1)
    
main()

### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    h, w, m = map(int, input().split())
    bomb_row = [0] * h
    bomb_col = [0] * w
    # 座標だけはsetで格納
    bomb_pos = set()
    # 爆弾情報を行と列ごとで格納
    for _ in range(m):
        r, c = [int(i) - 1 for i in input().split()]
        bomb_row[r] += 1
        bomb_col[c] += 1
        bomb_pos.add((r,c))

    bomb_row_max = max(bomb_row)
    bomb_col_max = max(bomb_col)

    row_index = [i for i, v in enumerate(bomb_row) if v == bomb_row_max]
    col_index = [i for i, v in enumerate(bomb_col) if v == bomb_col_max]
    ans = bomb_col_max + bomb_row_max
    for row in row_index:
        for col in col_index:
            if (row, col) not in bomb_pos:
                print(ans)
                return
    print(ans-1)
main()
n, k = [int(x) for x in input().strip().split(" ")]
p = 10**9 + 7

num_list = [int(x) for x in input().strip().split(" ")]
num_list = sorted(num_list, reverse = True)
ans = 1
l_idx = 0
r_idx = -1

while True:
  if k >= 2:
    l_prod = num_list[l_idx] * num_list[l_idx+1]
    r_prod = num_list[r_idx] * num_list[r_idx-1]
    if l_prod >= r_prod:
      ans *= l_prod % p
      ans %= p
      l_idx +=2
      k -= 2
    else:
      ans *= r_prod % p
      ans %= p
      r_idx +=2
      k -= 2
  elif k == 1:
    ans *= num_list[l_idx] % p
    ans %= p
    break
  else:
    break
        
if num_list[0] < 0 and k % 2 == 1:
  ans = 1
  for i in range(k):
    ans *= num_list[i]
    ans %= p

print(ans)


### FIXED CODE ###

n = int(input().rstrip())

print((1000-n)%1000)
from collections import defaultdict as dd
N, C = tuple(map(int, input().split()))
events = []
tmax = 0
dic=dd(list)
for i in range(N):
    s, t, c = map(int, input().split())
    dic[c].append((s,t))
eps = 0.5
for k,v in dic.items():
    v1 = sorted(v)
    lev = len(v)
    prev = [-1,-1]
    for i,val in enumerate(v1):
        if tmax < val[1]:
            tmax = val[1]
        if prev == [-1,-1]:
            prev[0] = val[0]
            prev[1] = val[1] # end_time
            if lev != 1:
                continue
            else:
                events.append((prev[0]-eps, 1))
                events.append((prev[1], 0))
                break
        if prev[1] == val[0]:# prev_end == now_start
            prev[1] = val[1]
        else:
            events.append((prev[0]-eps, 1))
            events.append((prev[1], 0))
            prev = val
        if i==lev-1:
            events.append((prev[0]-eps, 1))
            events.append((prev[1], 0))
events.sort()
idx = 0
cnt = 0
res = 0
events.append((0,-1))
for t in range(tmax + 1):
    while events[idx][0] <= t:
        event = events[idx]
        if event[1] == 1:
            cnt += 1
            if res < cnt:
                res = cnt
        elif event[1] == 0:
            cnt -= 1
        else:
            break
        idx += 1
print(res)

### FIXED CODE ###

from collections import defaultdict as dd
N, C = tuple(map(int, input().split()))
events = []
tmax = 0
dic=dd(list)
for i in range(N):
    s, t, c = map(int, input().split())
    dic[c].append((s,t))
eps = 0.5
for k,v in dic.items():
    v1 = sorted(v)
    lev = len(v1)
    prev = [-1,-1]
    for i,val in enumerate(v1):
        if tmax < val[1]:
            tmax = val[1]
        if prev == [-1,-1]:
            prev[0] = val[0]
            prev[1] = val[1] # end_time
            if lev != 1:
                continue
            else:
                events.append((prev[0]-eps, 1))
                events.append((prev[1], 0))
                break
        if prev[1] == val[0]:# prev_end == now_start
            prev[1] = val[1]
            if i == lev - 1:
                events.append((prev[0] - eps, 1))
                events.append((prev[1], 0))
                break
        else:
            events.append((prev[0]-eps, 1))
            events.append((prev[1], 0))
            prev[0] = val[0]
            prev[1] = val[1]
            if i==lev-1:
                events.append((val[0]-eps, 1))
                events.append((val[1], 0))
                break
events.sort()
idx = 0
cnt = 0
res = 0
events.append((0,-1))
for t in range(tmax + 1):
    while events[idx][0] <= t:
        event = events[idx]
        if event[1] == 1:
            cnt += 1
            if res < cnt:
                res = cnt
        elif event[1] == 0:
            cnt -= 1
        else:
            break
        idx += 1
print(res)
X, Y = map(int, input())
print(X+(Y/2))

### FIXED CODE ###

X, Y = map(int, input().split())
print(int(X+(Y/2)))
a,b=map(int,input().split())
s=input()

s[b-1]=s[b-1].lower()
print(s)

### FIXED CODE ###

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

print(s[:b-1]+s[b-1].lower()+s[b:])
n, m = map(int, input().split())
s, c = [], []
for i in range(m):
    a, b = map(input().split())
    s.append(a), c.append(b)
loop = True

for i in range(10 ** (n - 1), 10 ** n):
    string = str(i)
    for j in range(m):
        if string[s[j] - 1] != c[j]:
            break
        if j == m - 1:
            print(string)
            loop = False
    if loop == False:
        break
    if i == 10 ** n - 1:
        print('-1')
        

### FIXED CODE ###

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


for i in range(0, 10 ** n):
    loop = True
    string = str(i)
    if len(string) != n:
        continue
    for j in range(m):
        if string[s[j] - 1] != str(c[j]):
            loop = False
    if loop:
        print(string)
        exit()

print('-1')
r = int(input("r--->"))
g = int(input("g--->"))
b = int(input("b--->"))

if r < 0 and r > 9:
    print("0<=r<=9")
if g < 0 and g > 9:
    print("0<=g<=9")
if b < 0 and b > 9:
    print("0<=b<=9")

s = 100*r+10*b+g

if r%4 == 0:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

r, g, b = (int(x) for x in input().split())


s = 100*r+10*g+b

if s%4 == 0:
    print("YES")
else:
    print("NO")
N,P=map(int,input().split())
Q=[0]*(10**6+1)

i=2

while 1:
  if P==1:
    break
  if P%i==0:
    P//=i
    Q[i]+=1
    i=2
  else:
    i+=1
#print(Q[:20])
#print(list(map(lambda x: x//N,Q)))
Q=list(map(lambda x: x//N,Q))

ans=1
for i,q in enumerate(Q):
  if q:
    ans*=i**q
print(ans)

### FIXED CODE ###

N,P=map(int,input().split())
Q=[0]*(10**6+1)

i=2

if N==1:
  print(P)
  exit()

while 1:
  if P==1 or i>=10**6:
    break
  if P%i==0:
    P//=i
    Q[i]+=1
    i=2
  else:
    i+=1
#print(Q[:20])
#print(list(map(lambda x: x//N,Q)))
Q=list(map(lambda x: x//N,Q))

ans=1
for i,q in enumerate(Q):
  if q:
    ans*=i**q
print(ans)
t=input()
import math
print (math.log(t)-math.log(100))/math.log(1.01)

### FIXED CODE ###

t=int(input())
k=100000
p=100
for i in range(1,k):
	p=int(p*1.01)
	if (p>=t):
		print (i)
		break
#coding:utf-8
n,k=map(int,input().split())
h=[int(input()) for i in range(n)]
h.sort()
print(min(h[i+k-1]-h[i] for i in range(n-k+1)))

### FIXED CODE ###

#coding:utf-8
d=int(input())
if d==25:
	print("Christmas")
elif d==24:
	print("Christmas Eve")
elif d==23:
	print("Christmas Eve Eve")
elif d==22:
	print("Christmas Eve Eve Eve")
else:
	print("")
n = input()
N = int(n)
sum = 0

for i in range(N+1):
    if N % 3 == 0:
        print(Fizz)
    elif N % 5 == 0:
        print(Buzz)
    elif N % 15 == 0:
        print(FizzBuzz)
    else:
     sum += N

print (sum)

### FIXED CODE ###

n = int(input())
sum = 0
 
for i in range(n+1):
    if i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    elif i % 15 == 0:
        pass
    else:
     sum += i
 
print (sum)
a,b,k=map(int,input().split());*r,=range(a,b+1);print(*sorted({*r[:k]+r[-k:]}))

### FIXED CODE ###

a,b,k=map(int,input().split());r=range(a,b+1);print(*sorted(set(r[:k])|set(r[-k:])),sep='\n')
N,K = map(int, input().split())
c = 1
K_ = 1
i=True
while i==True:
  K_ = K_ * K
  if N < K_:
    print(c)
    i=False
  counter += 1

### FIXED CODE ###

N,K = map(int, input().split())
c = 1
K_ = 1
i=True
while i==True:
  K_ = K_ *K
  if N < K_:
    print(c)
    i=False
  c += 1