Harryxun/stf_run huggingface dataset:
def power_mod(a,b,mod=10**9+7):
    i,temp,box=0,b,[]
    while(2**i<=b):
        i+=1
    for j in range(i-1,-1,-1):
        box=[[j,temp//2**j]]+box
        temp-=2**j*(temp//2**j)
    box[0].append(a)
    ans=box[0][1]*a%mod
    for j in range(1,i):
        box[j].append(box[j-1][2]**2%mod)
        if box[j][1]==1:
            ans=(ans*box[j][2])%mod
    return ans
def n_func(n,mod=10**9+7):
    ans=1
    for i in range(1,n+1):
        ans=(ans*i)%mod
    return ans
def nPr(n,r,mod=10**9+7):
    ans=n_func(n-r,mod)
    ans=power_mod(ans,mod-2,mod)
    return ans*n_func(n,mod)%mod
def nCr(n,r,mod=10**9+7):
    ans=n_func(n-r,mod)*n_func(r,mod)%mod
    ans=power_mod(ans,mod-2,mod)
    return ans*n_func(n,mod)%mod

N,M,K=map(int,input().split())
keisuu=nCr(N*M-2,K-2,mod)

sum_=0
for i in range(N):
    a=min(abs(i),abs(N-i-1))
    b=max(abs(i),abs(N-i-1))
    sum_+=(M**2)*((a*(a+1)//2)+(b*(b+1)//2))
for i in range(M):
    a=min(abs(i),abs(M-i-1))
    b=max(abs(i),abs(M-i-1))
    sum_+=(N**2)*((a*(a+1)//2)+(b*(b+1)//2))
print((keisuu * (sum_//2))%mod)

### FIXED CODE ###

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

A=2*10**5
mod = 10**9+7
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, A + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N,M,K=map(int,input().split())
keisuu=cmb(N*M-2,K-2,mod)

sum_=0
for i in range(N):
    a=min(abs(i),abs(N-i-1))
    b=max(abs(i),abs(N-i-1))
    sum_+=(M**2)*((a*(a+1)//2)+(b*(b+1)//2))
for i in range(M):
    a=min(abs(i),abs(M-i-1))
    b=max(abs(i),abs(M-i-1))
    sum_+=(N**2)*((a*(a+1)//2)+(b*(b+1)//2))
print((keisuu * (sum_//2))%mod)
y,m,d = int(input().split("/"))
print("Heisei" if y<=2019 and m<=4 and d<=30 else "TBD")

### FIXED CODE ###

s = input()
print("Heisei" if s<="2019/04/30" else "TBD")
import sys

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, (input().split(' '))))
    B = list(map(int, (input().split(' '))))

    a_sum = 0
    for x in A:
        a_sum += x
    b_sum = 0
    for x in B:
        b_sum += x
    if a_sum > b_sum:
        print('No')
        sys.exit()
    if (a_sum + N) < b_sum:
        print('No')
        sys.exit()
    a_plus = 0
    b_plus = 0
    for i in range(N):
        if A[i] < B[i]:
            a_plus += (B[i] - A[i])
        else:
            b_plus += (A[i] - B[i])
    if a_plus < b_plus * 2:
        print('No')
        sys.exit()
    print('Yes')

### FIXED CODE ###

import sys

if __name__ == "__main__":
    X, Y = map(int, (input().split(' ')))
    max = X
    min = Y
    if X < Y:
        print(X)
        sys.exit()
#        max = Y
#        min = X
    if max % min == 0:
        print(-1)
        sys.exit()
    sho = (pow(10, 18) // X)  + 1
    for i in range(1, sho):
        num = X * i
        if (num % Y != 0):
            print(num)
            sys.exit()
    print(-1)
S = input()
arr =['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
print(arr[arr.index(S)+1])

### FIXED CODE ###

S = input()
arr =['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
print(7-arr.index(S))
import math
from fractions import gcd
from functools import reduce

N = int(input())
T = [int(input()) for i in range(N)]


def gcd(numbers):  # "numbers" is list
    return reduce(gcd, numbers, 1)


def lcm_base(x, y):
    return (x * y) // gcd(x, y)


def lcm(numbers):  # "numbers" is list
    return reduce(lcm_base, numbers,
                  1)  # [third argument] return 1 if "numbers" is empty


print(lcm(T))

### FIXED CODE ###

import math
from functools import reduce

N = int(input())
T = [int(input()) for i in range(N)]

# def gcd(numbers):  # "numbers" is list
#     return reduce(math.gcd, numbers)

# def lcm_base(x, y):
#     return (x * y) // math.gcd(x, y)


#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


#a,bの最小公倍数
def lcm_base(a, b):
    return a * b // gcd(a, b)


def lcm(numbers):  # "numbers" is list
    return reduce(lcm_base, numbers,
                  1)  # [third argument] return 1 if "numbers" is empty


print(lcm(T))
# coding: utf-8
def main():
    N,Q = map(int, input().split())
    s = input()
    ans = N
    command = []

    # print(char_list)

    for i in range(Q):
        t,d = input().split()
        command.append([t,d])

    r = binary_serch_R(command,s,N)
    #print(r)
    l = binary_serch_L(command,s,N)
    #print(l)
    ans = ans - (N-r) - (l+1)
    if ans < 0:
        ans = 0
    print(ans)

def simulation_R(command,s,now,N):
    for pair in command:
        if pair[0] == s[now]:
            if pair[1] == 'L':
                now -= 1
            elif pair[1] == 'R':
                now += 1
        if now < 0:
            return False
        elif now >= N:
            return True
    return False

def simulation_L(command,s,now,N):
    for pair in command:
        if pair[0] == s[now]:
            if pair[1] == 'L':
                now -= 1
            elif pair[1] == 'R':
                now += 1
        if now < 0:
            return True
        elif now >= N:
            return False
    return False


def binary_serch_R(command,s,N):
    left = 0
    right = N-1
    if simulation_R(command,s,left,N) :
        return -1
    if simulation_R(command,s,right,N) == False:
        return N

    while abs(right - left) > 1:
        mid = int((left+right)/2)
        # print(mid)
        if simulation_R(command,s,mid,N) :
            right = mid
        else :
            left = mid 
    return right

def binary_serch_L(command,s,N):
    left = 0
    right = N-1
    if simulation_L(command,s,left,N) == False :
        return -1
    if simulation_L(command,s,right,N):
        return N
        
    while abs(right-left) > 1:
        mid = int((left+right)/2)
        if simulation_L(command,s,mid,N) :
            left = mid
        else :
            right = mid 
    return left

if __name__ == "__main__":
    main()

### FIXED CODE ###

# coding: utf-8
def main():
    a,b,c = map(int, input().split())
    if a==b and b == c:
        print("Yes")
    else:
        print("No")
if __name__ == "__main__":
    main()
class RollingHash:

    def __init__(self, string, root, mod):
        self.root = root
        self.mod = mod
        self.hs = [0] * (len(string) + 1)
        self.pw = [1] * (len(string) + 1)
        for i in range(len(string)):
            self.hs[i + 1] = (self.hs[i] * self.root + ord(string[i])) % self.mod
            self.pw[i + 1] = self.pw[i] * self.root % self.mod

    def get_hash(self, l, r):
        "get the hash of s[l:r] (0 <= l <= r <= len(s))"
        return (self.hs[r] - self.hs[l] * self.pw[r - l]) % self.mod

    def __getitem__(self, index):
        if isinstance(index, slice):
            return self.get_hash(index.start, index.stop)
        else:
            return 0


RHMOD = (1 << 61) - 1
POSITIVIZER = RHMOD << 20
class RollingHashMOD61:
    """
    MOD == 2 ** 61 - 1
    参考: https://qiita.com/keymoon/items/11fac5627672a6d6a9f6
    """


    def __init__(self, string, root):
        self.root = root
        self.hs = [0] * (len(string) + 1)
        self.pw = [1] * (len(string) + 1)
        for i in range(len(string)):
            tmp = self.hs[i] * self.root + ord(string[i])
            self.hs[i + 1] = (tmp >> 61) + (tmp & RHMOD)
            tmp = self.pw[i] * self.root
            self.pw[i + 1] = (tmp >> 61) + (tmp & RHMOD)

    def get_hash(self, l, r):
        "get the hash of s[l:r] (0 <= l <= r <= len(s))"
        ret = (self.hs[r] - self.hs[l] * self.pw[r - l] + POSITIVIZER)
        ret = (ret >> 61) + (ret & RHMOD)
        if ret >= RHMOD:
            ret -= RHMOD
        assert 0 <= ret < RHMOD
        return ret

    def __getitem__(self, index):
        if isinstance(index, slice):
            return self.get_hash(index.start, index.stop)
        else:
            return 0
        
if __name__ == "__main__":
    N = int(input())
    S = input()

    MOD = 2 ** 61 - 1
    root = 10000

    rh = RollingHashMOD61(S, root)

    ok = 0
    ng = N
    while ng - ok > 1:
        mid = (ok + ng) // 2
        hashes = dict()
        flg = False
        for i in range(N - mid + 1):
            hashofsub = rh[i:i+mid]
            if hashofsub in hashes:
                if i >= hashes[hashofsub] + mid:
                    flg = True
                    break
            else:
                hashes[hashofsub] = i
        
        if flg:
            ok = mid
        else:
            ng = mid

    print(ok)


### FIXED CODE ###

N = int(input())
S = input()

ans = 0
while S:
    Z = [0] * N
    i = 1
    j = 0
    while i < N:
        while i + j < N and S[j] == S[i + j]:
            j += 1

        Z[i] = j

        if j == 0:
            i += 1
        else:
            k = 1
            while k < j and k + Z[k] < j:
                Z[i + k] = Z[k]
                k += 1
            i += k
            j -= k    

    ans = max(ans, max(min(i, z) for i, z in enumerate(Z)))

    S = S[1:]
    N -= 1

print(ans)
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys

INF = float('inf')


def solve(S: str, T: str):
    return len(T) - max(sum(s == t for s, t in zip(S[i:], T)) for i in range(len(S) - len(T)))


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    print(f'{solve(S, T)}')


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys

INF = float('inf')


def solve(S: str, T: str):
    return len(T) - max(sum(s == t for s, t in zip(S[i:], T)) for i in range(len(S) - len(T) + 1))


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    print(f'{solve(S, T)}')


if __name__ == '__main__':
    main()
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
N,K = map(int,input().split())
A = list(map(int,input().split()))
if N == 1:
    print(1)
else:
    else:
        old = A
        for _ in range(K):
            li = [0]*N
            for i in range(N):
                MIN = max(0,i-old[i])
                MAX = min(N-1,i+old[i])
                li[MIN] += 1
                if MAX != N-1:
                    li[MAX+1] -= 1
            old = accumulate(li)
            old = list(old)
            if min(old) == N:
                break
        print(*old)


### FIXED CODE ###

import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
N,K = map(int,input().split())
A = list(map(int,input().split()))
if N == 1:
    print(1)
else:
    
    old = A
    for _ in range(K):
        li = [0]*N
        for i in range(N):
            MIN = max(0,i-old[i])
            MAX = min(N-1,i+old[i])
            li[MIN] += 1
            if MAX != N-1:
                li[MAX+1] -= 1
        s = 0
        for i in range(N):
            s += li[i]
            old[i] = s
        if min(old) == N:
            break
    print(*old)
S = input()
ans = min(max(map(len, S.split(c)))
          for c in [chr(i + 97) for i in range(26)]
          if c not in S))
print(ans)

### FIXED CODE ###

S = input()
ans = len(S)
for tgt in set(S):
    T = S
    while len(T) != T.count(tgt):
        U = ''
        for ab in zip(T, T[1:]):
            U += tgt if tgt in ab else ab[0]
        T = U
    ans = min(ans, len(S) - len(T))
print(ans)
h, w = (list)(map(int, input().split()))
l = [[lin for lin in input()] for _ in range(h)]

gri = [[0 for i in range(w+2)] for _ in range(h+2)]
for i in range(h+2):
    for j in range(w+2):
        if i == 0 or i == h+1 or j == 0 or j == w+1:
            gri[i][j] = '.'
        else:
            gri[i][j] = l[i-1][j-1]


flag = 0
for i in range(1, h+1):
    for j in range(1, w+1):
        if gri[i][j] == '#':
            flag += 1
            if gri[i-1][j] == '.' and gri[i+1][j] == '.' and gri[i][j-1] == '.' and gri[i][j+1] == '.':
                print("No")
                exit(1)

if flag >= 2:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

h, w = (list)(map(int, input().split()))
l = [[lin for lin in input()] for _ in range(h)]

gri = [['.' for i in range(w+2)] for _ in range(h+2)]
for i in range(1, h+1):
    for j in range(1, w+1):
        gri[i][j] = l[i-1][j-1]

flag = 1
for i in range(1, h+1):
    for j in range(1, w+1):
        if gri[i][j] == '#':
            if gri[i-1][j] == '.' and gri[i+1][j] == '.' and gri[i][j-1] == '.' and gri[i][j+1] == '.':
                flag = 0
if flag == 1:
    print("Yes")
else:
    print("No")
import numpy as np

N=int(input())
Rain = np.array(list(map(int,input().split())))
Rain = np.reshape(Rain,(N,1))

n1 = np.ones(N)
n2 = np.ones(N-1)
a = np.diag(n1)
b = np.diag(n2,k=1)
c = a+b
c[N-1][0] = 1
d = 0.5 * c

ans = np.linalg.solve(d,Rain)
for i in ans:
    print(int(i[0]),end=" ")

### FIXED CODE ###

N=int(input())
a = list(map(int,input().split()))
S = sum(a)
S1 = 0
for i in range(N):
    if i%2 == 1:
        S1 += a[i]
b = [0 for i in range(N)]
b[0] = S - 2*S1
print(b[0],end=' ')
for j in range(1,N):
    b[j] = 2*a[j-1] - b[j-1]
    print(b[j],end=' ')
n, q = list(map(int,input().split()))
s = input()
l = []
for i in range(q) :
    l.append(list(map(int,input().split())))
pla = []
for i in range(len(s)) :
    if s[i] == "A" :
        if s[i+1] == "C" :
            pla.append(i)
for i in l :
    count = 0
    for j in pla :
        if i[0] - 1 <= j < i[1] - 1 :
            count += 1
    print(count)


### FIXED CODE ###

n,q= map(int,input().split())
s = input()
l = [list(map(int,input().split())) for i in range(q)]
sa = [0]*n
for i in range(0,len(s)-1):
    if s[i] == "A" and s[i+1] == "C":
        sa[i+1] = sa[i] + 1
    else:
        sa[i+1] = sa[i]

""" A C D D D A C A C """
"""0 1 1 1 1 1 2 2 3  """
for si, syu in l:
    print(sa[syu-1] - sa[si-1])
N, K = map(int, input().split())
h = list(map(int, input().split()))

INF = sum(h)*2
dp = [0 for _ in range(N)]

for i in range(1, N):
  dp[i] = min([dp[i-j-1]+abs(h[i]-h[i-j-1]) for j in range(min(i,K))])

print(dp[N-1])


### FIXED CODE ###

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

if N == 2:
  print(abs(h[1]-h[0]))
  exit()

dp = [0 for _ in range(N)]
dp[1] = abs(h[1] - h[0])
for i in range(2, N):
  dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]))

print(dp[N-1])
N = int(input())
C=list(input())
L=0
R=0
X=0
for i in range(N):
  L=i
  if L==N-1-R:
    break
  if C[i]=='W':
    for ii in range(N-L-R):
      R+=ii 
      if C[N-1-R]=='R':
        C[L]='R'
        C[N-1-R]='W'
        X+=1
        R+=1
        if L==N-1-R:
          break
        break
print(X)


### FIXED CODE ###

N = int(input())
C=list(input())
type=set(C)
L=0
R=0
RR=0
X=0
if 'R' in type and 'W' in type:
    for i in range(N):
      L=i
      R=RR
      if L>=N-1-R:
        break
      if C[i]=='W':
          for ii in range(N-L-R):
            if C[N-1-R-ii]=='R':
              C[L]='R'
              C[N-1-R-ii]='W'
              X+=1
              break
            RR+=1
            if L>=N-1-R:
              break
print(X)
string = input()
nums = [int(v) for v in string]
length = len(string) - 1
k = int(string)
d = int(input())

M = 10**9 + 7
def mod(v):
    if v >= M:
        return v % M
    return v

dp = [[[None] * 2 for _ in range(d * 100)] for _ in range(length + 2)]
def dfs(i=0, s=0, border=True):
    if dp[i][s][border] is not None:
        return dp[i][s][border]

    if i > length:
        r = not bool(s)
        dp[i][s][border] = r
        return r

    cnt = 0
    for n in range(max(9 * (not border), nums[i]) + 1):
        cnt = mod(cnt + dfs(i + 1, (s + n) % d, border and nums[i] == n))
    dp[i][s][border] = cnt
    return cnt

print(mod(dfs() - 1))


### FIXED CODE ###

string = input()
d = int(input())

nums = [int(v) for v in string]
length = len(string) - 1
k = int(string)

M = 10**9 + 7
def mod(v):
    if v >= M:
        return v % M
    return v

dp = [[[None] * 2 for _ in range(d)] for _ in range(length + 2)]
def dfs(i=0, s=0, border=True):
    if dp[i][s][border] is not None:
        return dp[i][s][border]

    if i > length:
        r = int(not bool(s))
        dp[i][s][border] = r
        return r

    cnt = 0
    for n in range(max(9 * (not border), nums[i]) + 1):
        cnt = mod(cnt + dfs(i + 1, (s + n) % d, border and nums[i] == n))
    dp[i][s][border] = cnt
    return cnt
# print(mod(dfs() - 1))

for i in reversed(range(length + 2)):
    for s in reversed(range(d)):
        for border in [False, True]:
            if i > length:
                dp[i][s][border] = int(not bool(s))
                continue

            cnt = 0
            for n in range(max(9 * (not border), nums[i]) + 1):
                cnt = mod(cnt + dp[i + 1][(s + n) % d][border and nums[i] == n])
            dp[i][s][border] = cnt

print(mod(dp[0][0][1] - 1 + M))
N=int(input())
a=[int(x) for x in input().split()]
a.sort()
set_a=list(set(a))
if N % 2 ==0:
	for i in range(N):
		a[i] != 2*(i // 2) + 1
		print(0)
		exit(0)
else:
	if a[0] != 0:
		print(0)
		exit(0)
	else:
		for i in range(1,N):
			a[i] != 2(i+1 // 2) +1
			print(0)
			exit(0)
if N % 2==1:
	len=len(set_a)-1
else:
	len=len(set(a))
ans=2**len
print(ans)

### FIXED CODE ###

import numpy as np
MOD = 10**9 + 7
N = int(input())
A = np.array([int(x) for x in input().split()])

left = np.arange(N)
right = N-1-left
cnt_1 = np.bincount(np.abs(left-right))
cnt_2 = np.bincount(A)

if cnt_1.shape != cnt_2.shape or (cnt_1 != cnt_2).any():
  answer = 0
else:
  answer = pow(2, N//2, MOD)
  
print(answer)
def make_divisors(n):
    divisors = []
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    divisors.append(n)
    return divisors

def check(N,K):
    if N == K:
        return True
    if N % K ==1:
        return True
    if N<K:
        return False
    
    if N % K ==0:
        return check(N//K,K)
    else:
        return False


def resolve():
    N = int(input())
    ys= set(make_divisors(N))
    ys2= set(make_divisors(N-1))
    x =set([i for i in ys2 if check(N,i)])
    x2 =set([i for i in ys if check(N,i)])

    print(len(x|x2))


if __name__ == "__main__":
    resolve()


### FIXED CODE ###


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

    divisors.sort()
    divisors.append(n)
    return divisors

def check(N,K):
    try:
        if N == K:
            return True
        if N % K ==1:
            return True
        if N<K:
            return False
        
        if N % K ==0:
            return check(N//K,K)
        else:
            return False
    except:
        return False

def resolve():
    N = int(input())
    ys= set(make_divisors(N))
    ys2= set([i for i in make_divisors(N-1) if check(N,i)])

    x =set([i for i in ys if check(N,i)])

    print(len(x | ys2))


if __name__ == "__main__":
    resolve()
import re
import bisect
s = input()
len_s = len(s)
t = input()

ind_ls = [[j.start(0) for j in re.finditer(i,s)] for i in t]

def get_least(s_ind, ls):
    ind = bisect.bisect_right(ls, s_ind)
    if ind >= len(ls):
        return ls[0]
    else:
        return ls[ind]

if -1 in [s.find(_t) for _t in t]:
    print(-1)
else:
    cnt = 0
    last = get_least(0, ind_ls[0])
    for ind in ind_ls[1:]:
        _next = get_least(last, ind)
        if _next < last:
            cnt += 1
        last = _next
    print(cnt * len(s) + _next + 1)

### FIXED CODE ###

import bisect
s = input()
len_s = len(s)
t = input()

ind_dict = {i : [] for i in t}
for i, _s in enumerate(s):
    if _s in t:
        ind_dict[_s] += [i]

def get_least(last, s, dic):
    ls = dic[s]
    ind = bisect.bisect_right(ls, last)
    if ind >= len(ls):
        return ls[0]
    else:
        return ls[ind]

if -1 in [s.find(_t) for _t in t]:
    print(-1)
else:
    cnt = 0
    last = get_least(-1, t[0], ind_dict)
    _next = last
    for _t in t[1:]:
        _next = get_least(last, _t, ind_dict)
        if _next <= last:
            cnt += 1
        last = _next
    print(cnt * len(s) + _next + 1)
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m = MAP()
ans = [-1]*n

for i in range(m):
    s, c = MAP()
    s -= 1
    if ans[s] == -1 or ans[s] == c:
        ans[s] = c
    else:
        print(-1)
        exit()

if n != 1 and ans[0] == 0:
    print(-1)
    exit()
else:
    for i in range(m):
        if ans[i] == -1:
            if i == 0:
                ans[i] = 1
            else:
                ans[i] = 0
    print(*ans,sep='')

### FIXED CODE ###

from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m = MAP()
ans = [-1]*n

for i in range(m):
    s, c = MAP()
    s -= 1
    if ans[s] == -1 or ans[s] == c:
        ans[s] = c
    else:
        print(-1)
        exit()

if ans[0] == 0:
    if n == 1:
        print(0)
    else:
        print(-1)
    exit()
else:
    for i in range(n):
        if ans[i] == -1:
            if n != 1 and i == 0:
                ans[i] = 1
            else:
                ans[i] = 0
    print(*ans, sep='')