Harryxun/stf_run huggingface dataset:
def hantei(y,m):
    if y <= 12 and y >= 1:
        if m <= 12 and n >= 1:
            print('AMBIGUOUS')
        else:
            print('MMYY')
    else:
        if m <= 12 and n >= 1:
            print('YYMM')
        else:
            print('NA')
a = input()
b1 = int(a[0:2])
c2 = int(a[2:4])
henkan(b1,c2)


### FIXED CODE ###

a, b = map(int, input().split())
c = input()
print(c[:b-1]+str.lower(c[b-1])+c[b:])
a = int(input())
b = int(input())
c = int(b - a)
print(( c * (c - 1) //2 + c - b))


### FIXED CODE ###

a, b = map(int, input().split())
c = int(b - a)
d =int( c * (c - 1) // 2 + c  -b)
print(d)
N,Q = map(int,input().split())
Ki_Oya=dict()
Ki_Dict=dict()
Ki_Count=dict()
for i in range(N-1):
  A,B = input().split()
  if A not in Ki_Dict:
    Ki_Dict[A]=set(A)
    Ki_Count[A]=0
    Ki_Oya[A]=set(A)
  if B not in Ki_Dict:
    Ki_Dict[B]=set(B)
    Ki_Count[B]=0
    Ki_Oya[B]=Ki_Oya[A]
  
  Ki_Dict[A].add(B)
  if A in Ki_Oya:
    for j in list(Ki_Oya[A]):
      Ki_Dict[j].add(B)

for i in range(Q):
  P,X = input().split()
  X = int(X)
  for i in list(Ki_Dict[P]):
    Ki_Count[i] += X
Ki_List = list(Ki_Dict.keys())
ans=[]
for i in Ki_List:
  ans.append(str(Ki_Count[i]))
print(" ".join(ans))

### FIXED CODE ###

N,Q = map(int,input().split())
Ki_Oya=dict()
for i in range(N-1):
  A,B = map(int,input().split())
  Ki_Oya[B-1]=A-1
Counter_list=[0]*N
for i in range(Q):
  P,X=map(int,input().split())
  Counter_list[P-1] += X
print(Counter_list[0],end=" ")
for i in range(1,len(Counter_list)):
  Counter_list[i] += Counter_list[Ki_Oya[i]]
  print(Counter_list[i],end=" ")
print("")
n=int(input()) 
flag == False
for i in range(100*n,100*(n+1)):
  if i%108 == 0:
    x == int(i//108)
    print(x)
    flag == True
    break
if flag == False:
  print(':(')
  

### FIXED CODE ###

n=int(input()) 
flag = False
for i in range(100*n,100*(n+1)):
  if i%108 == 0:
    x = int(i//108)
    print(x)
    flag = True
    break
if flag == False:
  print(':(')
# 小さいのでメモ化再帰でいけるか？
# （[ここまでの回答数, ここまでの点数]みたいなやつ）
# んーーーーーー？？？？ RE*1、あとTLEになる。。。
# REはどうせ再帰の制限
import sys
sys.setrecursionlimit(10**10)

d, g = map(int, input().split())
memo = {}
points, bonus = [], []
for _ in range(d):
    p, c = map(int, input().split())
    points.append(p)
    bonus.append(c)


def f(c, p):
    if (c, p) in memo:
        return memo[(c, p)]
    if p >= g:
        return c
    ret = 10 ** 10
    for i in range(d):
        if points[i] == 1:
            points[i] = 0
            ret = min(ret, f(c + 1, p + (i + 1) * 100 + bonus[i]))
            points[i] = 1
        elif points[i] > 1:
            points[i] -= 1
            ret = min(ret, f(c + 1, p + (i + 1) * 100))
            points[i] += 1
        else:
            continue
    memo[(c, p)] = ret
    return ret


print(f(0, 0))


### FIXED CODE ###

# 未知のアルゴリズムか天才系DPかと思ってすぐ諦めて解説読んでしまった

d, g = map(int, input().split())
points = []
for _ in range(d):
    p, c = map(int, input().split())
    points.append((p, c))
ans = 10**12
for bit in range(2**d):
    arr = [False] * d
    for i in range(d):
        if bit >> i & 1 == 1:
            arr[i] = True
    tmp_sum = 0
    count = 0
    for i in range(d):
        if arr[i]:
            # kompuli-to
            tmp_sum += points[i][1]
            tmp_sum += (i + 1) * 100 * points[i][0]
            count += points[i][0]
    if tmp_sum < g:
        # 達成できるまで得点の高いやつからやっていく
        for i in range(d - 1, -1, -1):
            if arr[i]:
                # すでにkompuli-toしてるので
                continue
            used = 0
            for j in range(points[i][0]):
                if tmp_sum < g:
                    tmp_sum += (i + 1) * 100
                    count += 1
                    used += 1
            if used == points[i][0]:
                tmp_sum += points[i][1]
            if tmp_sum >= g:
                break
    ans = min(ans, count)
print(ans)
a=list(map(int,input().split()))
B=[]
for i in range(n,0,-1):
    if n//i>1:
        l=n//i
        cnt=0
        for k in range(2,l+1):
            cnt+=a[i*k-1]
        if cnt%2!=a[i-1]:
            B.append(str(i))
    else:
        if a[i-1]==1:
            B.append(str(i))

print(len(B))
if len(B)>0:
    for i in range(len(B)):
        B[i]=str(B[i])
    print(' '.join(B))

### FIXED CODE ###

import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


MOD = 10 ** 9 + 7


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = []
    C = [0] * N

    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

    for i in range(N):
        if A[N - i - 1] == 1:
            if C[N - i - 1] == 0:
                B.append(N - i)
                D = make_divisors(N - i)
                for d in D:
                    C[d - 1] += 1
                    C[d - 1] %= 2
        else:
            if C[N - i - 1] == 1:
                B.append(N - i)
                D = make_divisors(N - i)
                for d in D:
                    C[d - 1] += 1
                    C[d - 1] %= 2
    print(len(B))
    print(*B, sep=" ")


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

### FIXED CODE ###

b=input()
 
if b=='A':
    print('T')
elif b=='T':
    print('A')
elif b=='G':
    print('C')
else:
    print('G')
print(int(input()**3)

### FIXED CODE ###

n=int(input())

print(n**3)
o = list(input())
e = list(input())

for i in range( len(o) ) :
  print(o[i]+e[i],end="")

### FIXED CODE ###

o = list(input())
e = list(input())+['']

for i in range( len(o) ) :
  print(o[i]+e[i],end="")
N = int(input().strip())
array = list(map(int, input().strip().split()))
for i in array:
  if i % 2 == 0:
    if i % 3 == 0 or i % 5 == 0:
      fg = True
    else:
      fg = False
      print('DENIED')
      break
if fg:
  print('APPROVED') 

### FIXED CODE ###

N = int(input())
array = [int(x) for x in input().split()]
fl=True
for i in array:
  if i % 2 == 0:
    if i % 3 != 0 and i % 5 != 0:
        fl = False
if fl: print('APPROVED')
else:print('DENIED')
N = int(input())
ABC = [list(map(int, input().split())) for i in range(N-1)]
Q, K = map(int, input().split())
D = [0] * (N+1)
L = [[] for i in range(N+1)]
for a, b, c in ABC:
    L[a].append([b, c])
    L[b].append([a, c])


def dfs(n, np):
    for nc in L[n]:
        if nc[0] == np:
            continue
        else:
            D[nc[0]] = D[n] + nc[1]
            dfs(nc[0], n)


dfs(K, 0)
for i in range(Q):
    x, y = map(int, input().split())
    print(D[x] + D[y])


### FIXED CODE ###

import sys
sys.setrecursionlimit(500000)

N = int(input())
ABC = [list(map(int, input().split())) for i in range(N-1)]
Q, K = map(int, input().split())
D = [0] * (N+1)
L = [[] for i in range(N+1)]
for a, b, c in ABC:
    L[a].append([b, c])
    L[b].append([a, c])


def dfs(n, np):
    for nc in L[n]:
        if nc[0] == np:
            continue
        else:
            D[nc[0]] = D[n] + nc[1]
            dfs(nc[0], n)


dfs(K, 0)
for i in range(Q):
    x, y = map(int, input().split())
    print(D[x] + D[y])
a,b,c = map(int,input().split())
d = max(a,b,c)
print(9 * d + sum(a,b,c))

### FIXED CODE ###

a, b, c = map(int, (input().split()))
d = max(a,b,c)
print(d * 9 + a + b + c)
from collections import deque

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

A.sort()
d = deque()
for i in range(N-1):
    if A[i] != A[i+1]:
        d.append(A[i])
if A[N-1] != A[N-2]:
    d.append(A[N-1])

ans = 0
max_A = max(A)
ban = [0]*max_A
while len(d):
    num = d.popleft()
    if ban[num] != 1:
        ans += 1
        ban_num = num
        while ban_num <= max_A:
            ban[ban_num] = 1
            ban_num += num

print(ans)

### FIXED CODE ###

from collections import deque

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

A.sort()

ans = 0
max_A = max(A)
ban = [0]*(max_A+1)
again = list()

last = 0
for i in range(N-1):
    if A[i] == A[i+1] and A[i] != last:
        again.append(A[i])
        last = A[i]
if N > 1 and A[N-1] == A[N-2] and A[N-1] != last:
    again.append(A[N-1])

for num in again:
    ban_num = num
    while ban_num <= max_A:
        ban[ban_num] = 1
        ban_num += num
 
for num in A:
    if ban[num] != 1:
        ans += 1
        ban_num = num
        while ban_num <= max_A:
            ban[ban_num] = 1
            ban_num += num

print(ans)
from math import ceil
N = int(inpput())
print(ceil(N/2))

### FIXED CODE ###

from math import ceil
N = int(input())
print(ceil(N/2))
N = int(input())
a = [int(i) for i in input().split()]

from operator import mul
from functools import reduce

even_list = list(filter(lambda x:x%2==0, a))

if len(even_list) == 0:
    print(0)
else:
    m = reduce(mul, even_list)
    count = 0
    while True:
        m = m / 2
        count += 1
    
        if m % 2 == 1:
            break

    print(count)



### FIXED CODE ###

N = int(input())
a = [int(i) for i in input().split()]

from operator import mul
from functools import reduce

even_list = list(filter(lambda x:x%2==0, a))

if len(even_list) == 0:
    print(0)
else:

    count = 0

    for m in even_list:
    
        while True:
            m = m / 2
            count += 1
    
            if m % 2 == 1:
                break

    print(count)
input()
nums = [int(i) for i in input().split()]
maximium = max(nums)
minimium = min(nums)
sums = 0
for r in range(len(nums)):
    sums += nums[r]

print(maxinium, minimium, sums)

### FIXED CODE ###

input()
nums = [int(i) for i in input().split()]

maximum = max(nums)
minimum = min(nums)
total = sum(nums)

print(minimum, maximum, total)
n,m = map(int, input().split())

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

days = 0

for i in range(m):
    days += a[i]

remaining = n-days

if remaining < 0:
    print(-1)
else:
    print(remainig)

### FIXED CODE ###

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

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

days = 0

for i in range(m):
    days += a[i]

remaining = n-days

if remaining < 0:
    print(-1)
else:
    print(remaining)
def ch_min(a, b):
    if (a > b):
        a = b
    return a


if __name__ == "__main__":
    N = int(input())
    h = list(map(int, input().split()))
    INF = 10 ** 10
    dp = [INF] * 100010
    dp[0] = 0
    for i in range(N):
        dp[i + 1] = ch_min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))
        dp[i + 2] = ch_min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]))
    print(dp[N - 1])


### FIXED CODE ###

def ch_min(a, b):
    if (a > b):
        a = b
    return a


if __name__ == "__main__":
    N = int(input())
    h = list(map(int, input().split()))
    INF = 10 ** 10
    dp = [INF] * 100010
    dp[0] = 0
    for i in range(1, N):
        dp[i] = ch_min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
        if (i > 1):
            dp[i] = ch_min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))
    print(dp[N - 1])
def sieve():
    n = 10000001
    p = [1] * n
    p[0] = p[1] = 0
    
    for i in range(int(n ** 0.5)):
        if p[i]:
            for j in range(2 * i, len(p), i):
                p[j] = 0
    return p
import sys
f = sys.stdin

prime = sieve()
while True:
    ni = int(input())
    if ni == 0:
        break

### FIXED CODE ###

def get_quad(n, p):
    if n < 19:
        return 13
    n = (n + 1) // 10 * 10 - 1
    for ni in range(n,0,-10):
        if p[ni] and p[ni - 2] and p[ni - 6] and p[ni - 8]:
            return ni
        
def sieve():
    n = 10000001
    p = [1] * n
    p[0] = p[1] = 0
    
    for i in range(int(n ** 0.5)):
        if p[i]:
            for j in range(2 * i, len(p), i):
                p[j] = 0
    return p

import sys
f = sys.stdin

prime = sieve()
while True:
    n = f.readline().strip()
    if not n.isdigit():
        continue
    n = int(n)
    if n == 0:
        break
    print(get_quad(n, prime))
s = input()
t = input()
u = 0

if s == t:
  print(0)
else:
  for i in range(len(s)):
    if s[i] != t[i]:
      u += 1
    else:
      path

print(u)


### FIXED CODE ###

s = input()
t = input()
u = 0

if s == t:
  print(0)
else:
  for i in range(len(s)):
    if s[i] != t[i]:
      u += 1
  print(u)
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline


def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))

# mod=10**9+7
# rstrip().decode('utf-8')

#import numpy as np
from itertools import combinations

def main():
	n,k=MI()
	ans=10**18

	A=LI()
	A=[A[0]-1]+A

	for t in combinations(range(n),k):
		B=A.copy()
		tmp=0
		for i in t:
			i+=1
			B[i]=max(max(B[:i])+1,A[i])
			tmp+=B[i]-A[i]
		ans=min(ans,tmp)
	print(ans)

if __name__ == "__main__":
	main()


### FIXED CODE ###

import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline


def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))

# mod=10**9+7
# rstrip().decode('utf-8')

import numpy as np
from itertools import combinations

def main():
	n,k=MI()
	ans=10**18

	A=LI()
	A=[A[0]-1]+A
	A=np.array(A)

	for t in combinations(range(n),k):
		B=A.copy()
		tmp=0
		for i in t:
			i+=1
			B[i]=max(B[:i].max()+1,A[i])
			tmp+=B[i]-A[i]
		ans=min(ans,tmp)
	print(ans)

if __name__ == "__main__":
	main()
N = int(input())

ans = 0


for x in range(1, N + 1):
    ans_ = 0
    k = x
    for y in range(x):
        if x % 2 == 0:
            x /= 2
            ans_ += 1
        else:
            break
    if ans_ > ans:
        ans = ans_
        kk = k
print(kk)

### FIXED CODE ###

N = int(input())

ans = 0

kk = 1
for x in range(1, N + 1):
    ans_ = 0
    k = x
    for y in range(999):
        if x % 2 == 0:
            x /= 2
            ans_ += 1
        else:
            break
    if ans_ > ans:
        ans = ans_
        kk = k
print(kk)
K = int(input())
A = [int(i) for i in input().split()]

A.pop()

m, M = 2, 2
for a in A[::-1] :
    x = (2 * M - 1) // a
    M = a * x
  
if M >= 2 :
    print(M, M + A[0] - 1)
else :
    print(-1)

### FIXED CODE ###

K = int(input())
A = [int(i) for i in input().split()]

def solve() :            
    m, M = 2, 2
    for a in A[::-1] :
        if (m - 1) // a == M // a :
            return [-1]
            
        M = M // a * a + a - 1
        x = (m + a - 1) // a
        m = a * x
        
    return [m, M]
    
print(*solve())
k


### FIXED CODE ###

i = 1
while True:
  n = int(input())
  if n == 0:
    break
  print("Case ", i, ": ", n, sep = "")
  i = i+1
from sys import stdin
import string
import heapq
h,w = map(int,stdin.readline().rstrip().split())
s = ""
for i in range(h):
    s += stdin.readline().rstrip()
task_4 = (h//2)*(w//2)
task_2 = (h%2)*(h//2)+(w%2)*(w//2)
task_1 = (h%2)*(w%2)
alpha = string.ascii_lowercase
li = [-s.count(i) for i in alpha if s.count(i) != 0]
heapq.heapify(li)
for i in range(task_4):
    if li[0] <= -4:
        k = heapq.heappop(li)
        if k+4 == 0:
            continue
        else:
            heapq.heappush(li,k+4)
    else:
        print("No")
        exit()
for i in range(task_2):
    if li[0] <= -2:
        k = heapq.heappop(li)
        if k+2 == 0:
            continue
        else:
            heapq.heappush(li,k+2)
    else:
        print("No")
        exit()
for i in range(task_1):
    if li[0] <= -1:
        k = heapq.heappop(li)
        if k+1 == 0:
            continue
        else:
            heapq.heappush(li,k+1)
    else:
        print("No")
        exit()
print("Yes")

### FIXED CODE ###

from sys import stdin
import string
import heapq
h,w = map(int,stdin.readline().rstrip().split())
s = ""
for i in range(h):
    s += stdin.readline().rstrip()
task_4 = (h//2)*(w//2)
task_2 = (h%2)*(w//2)+(w%2)*(h//2)
task_1 = (h%2)*(w%2)
alpha = string.ascii_lowercase
li = [-s.count(i) for i in alpha if s.count(i) != 0]
heapq.heapify(li)
for i in range(task_4):
    if li[0] <= -4:
        k = heapq.heappop(li)
        if k+4 == 0:
            continue
        else:
            heapq.heappush(li,k+4)
    else:
        print("No")
        exit()
for i in range(task_2):
    if li[0] <= -2:
        k = heapq.heappop(li)
        if k+2 == 0:
            continue
        else:
            heapq.heappush(li,k+2)
    else:
        print("No")
        exit()
for i in range(task_1):
    if li[0] <= -1:
        k = heapq.heappop(li)
        if k+1 == 0:
            continue
        else:
            heapq.heappush(li,k+1)
    else:
        print("No")
        exit()
print("Yes")
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']
cnt = 26 * [0]
Input = ""

while True:
    I = input()
    if I == '':
        break
    Input += I

for i1 in range(len(alphabet)):
    for i2 in range(len(Input)):
        if 'A' <= Input[i2] <= 'Z':
            w = Input[i2].lower()
        else:
            w = Input[i2]
        if alphabet[i1] == w:
            cnt[i1] += 1
    print(alphabet[i1] + " : " + str(cnt[i1]))

### FIXED CODE ###

import sys

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']
cnt = 26 * [0]
Input = ""
loop = True

for I in sys.stdin:
    Input += I

for i1 in range(len(alphabet)):
    for i2 in range(len(Input)):
        if 'A' <= Input[i2] <= 'Z':
            w = Input[i2].lower()
        else:
            w = Input[i2]
        if alphabet[i1] == w:
            cnt[i1] += 1
    print(alphabet[i1] + " : " + str(cnt[i1]))
s = input()

n = s.count("hi")
print("Yes" if n*2 == len(n) else "No")

### FIXED CODE ###

s = input()

n = s.count("hi")
print("Yes" if n*2 == len(s) else "No")
N=int(input())
a = list(map(int, input().split()))
cnt=[0]*10000
for t in a:
    cnt[t] += 1
    cnt[t-1] += 1
    cnt[t+1] += 1
print(max(cnt))


### FIXED CODE ###

N=int(input())
a = list(map(int, input().split()))
cnt=[0]*100009
for t in a:
    cnt[t] += 1
    cnt[t-1] += 1
    cnt[t+1] += 1
print(max(cnt))
#!/usr/bin/env pypy3

import math

def num_cuts(A, ml):
	ret = 0
	for a in A:
		ret += (math.ceil(a / ml) - 1)
	return ret

def ok(A, ml):
	return num_cuts(A, ml) <= K

def ans(A, K):

	low = 0.5
	high = max(A)+1

	assert(not(ok(A, low)))
	assert(ok(A, high))

	while (high - low) > 0.1:
		mid = (low + high) / 2
		if ok(A, mid):
			high = mid
		else:
			low = mid

	low = max(1, math.floor(low) - 5)

	for i in range(100):
		p = low + i/3
		q = low + (i+1) / 3

		if not(ok(A, p)) and ok(A, q):
			return math.ceil(q)


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

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

print(ans(A, K))

### FIXED CODE ###

#!/usr/bin/env pypy3

import math

def num_cuts(A, ml):
	ret = 0
	for a in A:
		ret += (math.ceil(a / ml) - 1)
	return ret

def ok(A, ml):
	return num_cuts(A, ml) <= K

def ans(A, K):

	low = min(A) / (K+5)
	high = max(A)+1

	assert(not(ok(A, low)))
	assert(ok(A, high))

	while (high - low) > 0.1:
		mid = (low + high) / 2
		if ok(A, mid):
			high = mid
		else:
			low = mid

	low = max(1, math.floor(low) - 5)

	for i in range(100):
		p = low + i/2
		if ok(A, p):
			return math.ceil(p)

	assert(False)


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

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

print(ans(A, K))
import collections

N = int(input())
l = [input() for _ in range(H)]

c = collections.Counter(l)

L = c.most_common()

values, counts = zip(*c.most_common())

A = list(values)
B = list(counts)

b = B.count(B[0])

a = A[0:b + 1]

for i in a[0:]:
print(i)

### FIXED CODE ###

import collections
 
N = int(input())
l = [input() for _ in range(N)]
 
c = collections.Counter(l)
 
L = c.most_common()
 
values, counts = zip(*c.most_common())
 
A = list(values)
B = list(counts)
 
b = B.count(B[0])
 
a = A[0:b]
c = sorted(a)

for i in c[0:]:
		print(i)
a,b=map(int,input().split())
c=[]
d=[]
if a % 2 == 0:
    s = int(100*a/8)
    t = int(100*(a+1)/8) + 1
else:
    s = int(100*a/8) + 1
    t = int(100*(a+1)/8) 
u = int(100*b/10) 
v = int(100*(b+1)/10) + 1
for i in range(s,t):
    c.append(i)
for j in range(u,v):
    d.append(j)
c_d = set(c) & set(d)
if (len(c_d)>=0):
    print(min(c_d))
else:
    print(-1)



### FIXED CODE ###

a,b=map(int,input().split())
c=[]
d=[]
if a % 2 == 0:
    s = int(100*a/8)
    t = int(100*(a+1)/8) + 1
else:
    s = int(100*a/8) + 1
    t = int(100*(a+1)/8) 
u = int(10*b) 
v = int(10*(b+1)) 
for i in range(s,t):
    c.append(i)
for j in range(u,v):
    d.append(j)
c_d = set(c) & set(d)
if (len(c_d)>0):
    print(min(c_d))
else:
    print(-1)
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=q
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)

n,m = readInts()
sc = []
for i in range(m):
	tmp = readInts()
	sc.append([tmp[0]-1,tmp[1]])

if m==0:
	if n==1:
		print(0)
		exit()
	else:
		print(-1)
		exit()
ans = -1
for i in range(1000):
	*t, = map(int, list(str(i)))
	if len(t) != n:
        continue

	ch = True
	for j in range(m):
		if int(t[sc[j][0]])!=sc[j][1]:
			ch=False
			break
	if ch is True:
		print(i)
		quit()

print(-1)

### FIXED CODE ###

n,m = map(int, input().split())
s, c = [], []
for i in range(m):
    _s, _c = map(int, input().split())
    s.append(_s-1)
    c.append(_c)
 
for i in range(1000):
    *t, = map(int, list(str(i)))
 
    if len(t) != n:
        continue
 
    ok = True
    for j in range(m):
        if t[s[j]] != c[j]:
            ok = False
            break
 
    if ok:
        print(i)
        quit()
 
print(-1)
import math
r=int(input())
pritn(float(r*r*pi),float(2*r*pi))


### FIXED CODE ###

from math import pi
r=float(input())
print("{0:.6f}".format(r*r*pi),"{0:.6f}".format(2*r*pi))
N=int(input())
P=[int(input()) for n in range(N)]

a=-100
for i in range(N):
  if a<P[i]:
    a=P[i]

P.remove(a)

goukei=a/2
for j in range(N-1):
  goukei+=P[j]

print(int(goukei))

### FIXED CODE ###

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")
n, w = map(int, input().split())
wv = [tuple(map(int, input().split())) for i in range(n)]
#wv[i][0]:i番目の品物の重さ
#wv[i][1]:i番目の品物の価値

dp = [0]+[float"inf"]*(10**5)#dp[k]:価値kにおける最小重さ
for i in range(n):#あるi番目の品物について
    for j in range(10**5,wv[i][1]-1, -1):#ある価値jについて
        dp[j] = min( dp[j], dp[j-wv[i][1]]+wv[i][0] )
        #重さwv[i][0]であるi番目の品物を使うほうが価値jでの最小重さdp[j]が小さい場合は値を更新

res = 0
for v,e in enumerate(dp):#インデックスv(=ある価値j)における最小重さeについて
    if e <= w:
        res = v#最小重さが重さ制限を超えないならres更新
print(res)

### FIXED CODE ###

n, w = map(int, input().split())
wv = [tuple(map(int, input().split())) for i in range(n)]
#wv[i][0]:i番目の品物の重さ
#wv[i][1]:i番目の品物の価値

dp = [0]+[float("inf")]*(10**5)#dp[k]:価値kにおける最小重さ
for i in range(n):#あるi番目の品物について
    for j in range(10**5,wv[i][1]-1, -1):#ある価値jについて
        dp[j] = min( dp[j], dp[j-wv[i][1]]+wv[i][0] )
        #重さwv[i][0]であるi番目の品物を使うほうが価値jでの最小重さdp[j]が小さい場合は値を更新

res = 0
for v,e in enumerate(dp):#インデックスv(=ある価値j)における最小重さeについて
    if e <= w:
        res = v#最小重さが重さ制限を超えないならres更新
print(res)