peterverebics/CodeNet_Python_118 huggingface dataset:
n, m = map(int, input().split())
lis = [list(map(int, input().split())) for _ in range(m)]
ans = -1
if n == 1:
    i = 0
else:
    i = 10**(n-1)
while (ans == -1) & (i < 10**n):
    s = 0
    for j in lis:
        if str(i)[j[0]-1] == str(j[1]):
            s += 1
        else:
            s += 0
    if s == m:
        ans = i
    else:
        i += 1
print(ans)
N,M = map(int,input().split())
SC = []
for i in range(M):
    SC.append(list(map(int,input().split())))
for i in range(0,1000):
    si = str(i)
    if len(si) != N:
        continue
    flag = False
    for s,c in SC:
        s = s-1
        if si[s] != str(c):
            flag = True
    if not flag:
        print(i)
        exit()
print(-1)
n, m = map(int, input().split())
tmp = [10]*n

for _ in range(m):
    s,c = map(int, input().split())
    if tmp[s-1] == 10 or tmp[s-1]==c:
        tmp[s-1] = c
    else:
        print('-1')
        exit()

for i in range(n):
    if tmp[i] == 10:
        if i == 0 and n != 1:
            tmp[i] = 1
        else:
            tmp[i] = 0

ans = ''.join(map(str,tmp))

if n != 1 and ans[0] == '0':
    print('-1')
else:
    print(ans)
n, m = map(int, input().split())
s = []
c = []
number = 100000
for i in range(m):
    x, y = map(int, input().split())
    s = s + [x]
    c = c + [str(y)]
for i in range(1000):
    count = 0
    i_list = list(str(i))
    if len(i_list) == n:
        for j in range(m):
            if i_list[s[j] - 1] != c[j]:
                count += 1
        if count == 0:
            number = i
            break
if number < 10000:
    print(number)
else:
    print('-1')
def main():
  N, M = map(int,input().split())
  sc = list(list(input().split()) for _ in range(M))

  li = [""] * N

  for i in range(M):
    j = li[int(sc[i][0]) - 1]
    if j == "": li[int(sc[i][0]) - 1] = sc[i][1]
    elif j != sc[i][1]: return -1

  for i in range(N):
    if i == 0:
      if li[0] == "0" and N != 1: return -1
      if li[0] == "":
        if N == 1: li[0] = "0"
        else: li[0] = "1"
    elif li[i] == "": li[i] = "0"

  return "".join(li)

print(main())
n, m = map(int, input().split())
sc_ls = [list(map(int, input().split())) for _ in range(m)]

for num in range(10**n):
    if len(str(num)) != n:
        continue

    for s, c in sc_ls:
        if str(num)[s-1] != str(c):
            break
    else:
        print(num)
        break
else:
    print(-1)
N, M = [int(i) for i in input().split()]
S = [list(map(int,input().split())) for _ in range(M)]

bag =[]
for i in range(1000):
    ans = str(i)    
    if len(ans) == N:
        for j in range(M):
            if ans[S[j][0]-1] != str(S[j][1]):
                break
        else:# インナーループがbreakで終了しなかった
            bag.append(i)
            
if len(bag) != 0:
    print(min(bag))
else:
    print(-1)
n,m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

ans = ["0"] * n
if n>=2: ans[0] = "1"

ok = True
for s,c in sc:
    if s-1==0 and n>=2:
        if ans[s-1] == "1" or ans[s-1] == str(c): ans[s-1] = str(c)
        else: ok = False
    else:
        if ans[s-1] == "0" or ans[s-1] == str(c): ans[s-1] = str(c)
        else: ok = False

if n>=2:
    if ans[0] == "0": ok = False
print(-1 if not ok else "".join(ans))
N, M = map(int, input().split())

ans = []
neg = 0
for n in range(N):
  ans.append(-1)

for m in range(M):
  s, c = map(int, input().split())
  if ans[s-1] == -1:
    ans[s-1] = c
  elif ans[s-1] == c:
    pass
  else:
    neg = -1
    break

if ans[0] == 0 and N != 1:
  neg = -1

for j in range(len(ans)):
  if ans[j] == -1:
    ans[j] = 0

if N == 1:
  pass

elif ans[0] == 0:
  ans[0] = 1

if neg == -1:
  print(neg)
else:
  print("".join([str(i) for i in ans]))
n,m=(int(i) for i in input().split())
l=[None,None,None]
answer='unknown'
for i in range(m):
  a,b=(int(i) for i in input().split())
  if l[n-a]==None:
    l[n-a]=b
  elif l[n-a]!=b:
    answer='-1'
    break
if l[0]==None:
  l[0]=0
for i in range(3):
  if l[i]==None:
    if i!=n-1:
      l[i]=0
    else:
      l[i]=1
r=l[2]*10**2+l[1]*10+l[0]
if len(str(r))!=n:
  answer='-1'
if answer=='-1':
  print('-1')
else:
  print(r)
N, M = map(int, input().split())
f = 0
A = [-1 for i in range(N)]
for i in range(M):
  s, c = map(int, input().split())
  if A[s-1] != -1 and A[s-1] != c:
    print(-1)
    f = 1
    break
  A[s-1] = c
if f == 0:
  if N == 1 and (A[0] <= 0):
    print(0)
  elif N > 1 and A[0] == 0:
    print(-1)
  else:
    ans = 0
    for i in range(N):
      if i == 0:
        ans = ans * 10 + max(A[i], 1)
      else:
        ans = ans * 10 + max(A[i], 0)
    print(ans)
from collections import defaultdict
N,M = map(int,input().split())
SCs = [list(map(int,input().split())) for _ in range(M) ]

if N == 1:
    bottom = 0
else:
    bottom = 10 ** (N -1)
top = 10 ** (N)
ans = -1
for i in range(bottom,top):
    str_i = str(i)
    flag =True #条件を満たしていればTrue
    for q in SCs:
        s,c = q
        if int(str_i[s - 1]) != c:
            flag = False
    if flag:
        ans = i
        break
print(ans)
n,m = map(int, input().split()) 
sc = [list(map(int, input().split())) for _ in range(m)]
def check(num):
    num_str = str(num)
    if len(num_str) != n:
        return False
    for s, c in sc:
        if num_str[s-1] != str(c):
          return False
    return True

for i in range(1000):
    if check(i):
      	print(i)
      	exit()

print(-1)
import sys
N,M =map(int, input().split())
a = [input().split() for l in range(M)]

for i in range(1000):
    flag = 1
    b = str(i)
    if len(b)!= N:
        flag = 0
        continue
    for j in range(M):
        if b[int(a[j][0])-1] != a[j][1]:
            flag = 0
            break
    if flag == 1:
        print(i)
        sys.exit()

print("-1")
N,M = [int(x) for x in input().split(' ')]

ans_l = [0 for _ in range(N)]

ng = False

for _ in range(M):
    s, c = [int(x) for x in input().split(' ')]
    if s == 1 and c == 0 and N != 1:
        ng = True

    if ans_l[s-1] == 0 or ans_l[s-1] == c:
        ans_l[s-1] = c
    else:
        ng = True

if ans_l[0] == 0 and N != 1:
    ans_l[0] = 1

if ng:
    print(-1)
else:
    ans_l = [str(x) for x in ans_l]
    print(int(''.join(ans_l)))
n, m = map(int, input().split())
scs = [tuple(map(int, input().split())) for _ in range(m)]

mi = 0
if 2 <= n:
    mi += 10 ** (n - 1)
ma = 10 ** n
ans = -1

for i in range(mi, ma):
    st = str(i)
    tmp = True
    for j in range(m):
        if (int(st[scs[j][0] - 1]) != scs[j][1]):
            tmp = False
    if tmp:
        ans = i
        break
print(ans)
import sys
n,m = map(int,input().split())
s_c = [list(map(int,input().split())) for s in range(m)] #0 is s, 1 is c
l = 0
if n == 1:
	n,l = 0,9
elif n == 2:
	n,l =10,99
else:
	n,l = 100,999
for i in range(n,l+1):
	bol = True
	tmp = list(str(i))
	for j in range(m):
		k = s_c[j][0]
		if tmp[k-1] != str(s_c[j][1]):
			bol = False
	if bol:
		print(i)
		sys.exit()
print(-1)
n, m = map(int, input().split())
req = [list(map(int, input().split())) for i in range(m)]
for i in range(10000):
	st = str(i)
	if len(st) != n:
		continue
	ok = True
	for s, c in req:
		if int(st[s-1]) != int(c):
			ok = False
	if ok:
		print(st)
		exit(0)

print(-1)
N, M = map(int, input().split())


def answer():
    digs = [-1] * N
    for _ in range(M):
        s, c = map(int, input().split())
        s -= 1
        if digs[s] not in {c, -1}:
            return -1
        digs[s] = c
    if digs[0] == -1:
        digs[0] = int(N > 1)
    elif digs[0] == 0 and N > 1:
        return -1
    for i in range(1, N):
        if digs[i] == -1:
            digs[i] = 0
    return "".join(map(str, digs))


print(answer())
N,M = map(int,input().split())
SC = [tuple(map(int,input().split())) for i in range(M)]

if N==1:
    r = range(0,10)
elif N==2:
    r = range(10,100)
else:
    r = range(100,1000)

for n in r:
    n = str(n)
    for s,c in SC:
        s -= 1
        if n[s] != str(c):
            break
    else:
        print(n)
        exit()
print(-1)
n,m=list(map(int,input().split()))
if n==1 and m==0:
  print(0)
  exit(0)
d=[-1]*4
for _ in range(m):
  s,c=list(map(int,input().split()))
  if d[s]!=-1 and d[s]!=c:
    print(-1)
    exit(0)
  d[s]=c
ans=0
for i in range(1,n+1):
  if d[i]==-1:
    if ans==0:d[i]=1
    else:d[i]=0
  ans=10*ans+d[i]
if len(str(ans))==n:
  print(ans)
else:
  print(-1)
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)
n,m=map(int, input().split())
alist=[list(map(int, input().split())) for i in range(m)]
ans=-1
for i in range(999,-1,-1):
  if len(str(i))==n:
    x=True
    stri=str(i)
    for j in range(m):
      if stri[alist[j][0]-1]!=str(alist[j][1]):
        x=False
    if x:
      ans=i
print(ans)
def main():
    n,m = map(int, input().split())
    lim = 10 ** n
    val = [list(map(int, input().split())) for _ in range(m)]
    for i in range(10**(n-1) if n >= 2 else 0, lim):
        for j, k in val:
            j = j - 1
            l = str(i)
            if l[j] != str(k):
                break
        else:
             print(i)
             exit()
    print(-1)

if __name__ == '__main__':
    main()
n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]

arr=[str(i) for i in range(10**(n-1) if n>1 else 0,10**n)]

for x in arr:
  for i,tmp in enumerate(l):
    s,c=tmp
    if x[s-1]!=str(c):
      break
  else:
    print(x)
    exit()

print(-1)
(n,_),*t=[t.split()for t in open(0)]
n=int(n)
for i in range(10**(n-1)-(n<2),10**n):
  i=str(i)
  for s,c in t:
    if i[int(s)-1]!=c:
      break
  else:
    print(i)
    break
else:
  print(-1)
n, m = map(int, input().split())
dic = {}
ok = True
for i in range(m):
    a, b = map(int, input().split())
    if a in dic:
        if b != dic[a]:
            ok = False
    else:
        dic[a] = b

if 1 in dic:
    if n != 1 and dic[1] == 0:
        ok = False

if ok:
    l = ['0'] * n
    for i in dic.keys():
        l[i-1] = str(dic[i])
    if n != 1 and l[0] == '0':
        l[0] = '1'
    print(''.join(l))
else:
    print(-1)
#graph implementation
import math
n,m=map(int,input().split())
ans=['bal']*n
for i in range(m):
    s,c=map(int,input().split())
    if ans[s-1]=='bal':
      ans[s-1]=c
    else:
        if ans[s-1]!=c:
            print(-1)
            exit(0)
if ans[0]=='bal' and n>1:
    ans[0]=1
for i in range(n):
    if ans[i]=='bal':
        ans[i]=0
if ans[0]==0 and n>1:
    print(-1)
else:
    for i in ans:
        print(i,end="")
print()
N, M = map(int,input().split())
s = []
c = []
for i in range(M):
  S, C = map(int,input().split())
  s.append(S)
  c.append(C)


for i in range(10 ** (N + 1)):
  Str = str(i)
  
  if len(Str) == N and all([Str[s[j] - 1] == str(c[j]) for j in range(M)]):
      print(Str)
      exit()

print(-1)
n, m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(m)]
ans = -1
for i in range(1000):
	s = str(i)
	if len(s) == n:
		flag = 0
		for (x, y) in a:
			if int(s[x-1]) != y:
				flag = 1
		if flag == 0:
			ans = i
			break

print(ans)
x,m = map(int, input().split())
s=[-1]*m
c=[-1]*m
for i in range(m):
    s[i], c[i] = map(int, input().split())
if x ==1:
    start = 0
else:
    start = 10**(x-1)

for j in range(start, 1000):
    num = str(j)
    for k1, k2 in zip(s, c):
        if num[k1-1] != str(k2):
            break
    else:  #すべて一致したとき
        print(j)
        break
else:
    print(-1)
N, M = map(int, input().split())
ans = -1
S = [0] * M
C = [0] * M
for i in range(M):
    S[i], C[i] = map(int, input().split())

def check(x):
    if len(str(x)) != N:
        return False
    for s, c in zip(S, C):
        if str(x)[s-1] != str(c):
            return False    
    return True

for i in range(10**N):
    if check(i):
        ans = i
        break

print(ans)
import numpy as np
N,M=map(int, input().split())  
sc=np.array([list(map(int,list(input().split()))) for i in range(M)])

ans = np.zeros(N)
checked=False
for i in range(M):
  s=sc[i][0]
  c=sc[i][1]
  if N!=1 and s==1 and c==0:
    checked=True
    break
  for j in range(i):
    if s==sc[j][0] and c!=sc[j][1]:
      checked=True
      break
  ans[s-1] = c

if checked:
  print(-1)
else:
  if N!=1 and ans[0]==0:
    ans[0]=1
  res = ''
  for i in ans:
    res += str(int(i))
  print(int(res))
N, M = map(int, input().split())

lst = [list(map(int, input().split())) for _ in range(M)]
lst.sort(key=lambda x: x[0])

n = 10 ** N


for i in range(n):
    moji = str(i)
    k = len(moji)

    if k != N:
        continue

    flag = True

    for s, c in lst:
        if s > k or moji[s - 1] != str(c):
            flag = False
            break

    if flag:
        print(str(i))
        exit()

print('-1')
n, m = map(int, input().split())

listans = [0] * n
ans = 0

for i in range(m):
    s, c = map(int, input().split())
    s -= 1
    if listans[s] == 0:
        listans[s] = c
    elif listans[s] != c:
        ans = -1
    if n > 1 and s == 0 and c == 0:
        ans = -1

if n > 1 and listans[0] == 0:
    listans[0] = 1

if ans == 0:
    ans = "".join([str(li) for li in listans])

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

A=[-1]*n

ans=0
for i in range(m):
    s,c = map(int,input().split())
    if A[s-1]!=-1 and A[s-1]!=c :
        ans=-1
        break
    else:
        A[s-1]=c

if A[0]==0 and n!=1 :
    ans=-1

if ans==-1 :
    print(ans)
    exit()
    
if A[0]==-1 and n!=1 :
    A[0]=1
for i in range(n):
    ans*=10
    if A[i]==-1 :
        A[i] = 0
    ans += A[i]



print(ans)
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()
readlines = sys.stdin.buffer.readlines 

def check(n):
  x = str(n)
  if len(x) != N:
    return False
  for s, c in SC:
    if x[s-1] != str(c):
      return False
  return True
  
N, M = map(int, inp().split())
SC = [tuple(map(int, inp().split())) for _ in range(M)]

for i in range(1001):
  if check(i):
    print(i)
    exit()
print(-1)
N,M=map(int,input().split())
l=[0]*N
ans=0
for i in range(M):
    s,c=map(int,input().split())
    if l[s-1]==0 or l[s-1]==c:
        l[s-1]=c
    else:
        print(-1)
        exit()
    if s==1 and c==0 and N!=1:
        print(-1)
        exit()
for i in range(N):
    ans+=int(l[i])*(10**(N-i-1))
if N==len(str(ans)):
    print(ans)
else:
    print(10**(N-1)+ans)
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(str(C))

ans = -1

if n == 3:
    st, ed = 100, 1000
elif n == 2:
    st, ed = 10, 100
else:
    st, ed = 0, 10

for i in range(st, ed):
    t = list(str(i))
    for j in range(m):
        if t[s[j]] != c[j]:
            break
    else:
        ans = i
        break
print(ans)
n,m = map(int,input().split())
s = [0] * m
c = [0] * m
def ret():
	print(0)
	return
for i in range(m):
	s[i],c[i] = map(int,input().split())

def ret1():
	for i in range(0 if n == 1 else 10**(n-1),10**n):
		flag = 1
		for j in range(m):
			if i//(10**(n-s[j]))%10 != c[j]:
				flag = 0
		if flag == 1:
			print(i)
			return
	print(-1)
	return

if m == 1 and n == 1 and c[0] == 0:
	ret()
else:
	ret1()
N, M = map(int,input().split())
list1 = [tuple(map(int,input().split())) for _ in range(M)]
list2 = [None for _ in range(N)]
imp = False
for nums in list1:
  s, c= nums[0]-1, nums[1]
  if list2[s] == c or list2[s] == None:
    list2[s] = c
  else:
    imp = True
if list2[0] == None:
  if N ==1:
    list2[0] = 0
  else:
    list2[0] = 1

if (list2[0] == 0 and N != 1) or imp:
  print(-1)
else:
  for s in list2:
    if s == None:
      s = 0
    print("{}".format(s),end='')
n, m = map(int,input().split())
s = []
c = []
for _ in range(m):
  x, y = map(int,input().split())
  s.append(x)
  c.append(y)

for i in range(10 ** (n + 1)):
    Str = str(i)

    if len(Str) == n and all([Str[s[j] - 1] == str(c[j]) for j in range(m)]):
        print(Str)
        exit()

print(-1)
N,M=map(int,input().split())
s,c=[0]*M,[0]*M
for i in range(M):
    s[i],c[i] = map(int,input().split())
for i in range(10**N):
    if len(str(i)) != N:
        pass
    else:
        num=list(str(i))
        ok = True
        for j in range(M):
            if num[s[j]-1] != str(c[j]):
                ok = False
        if ok:
            print(i)
            exit()
print(-1)
import sys

N, M = map(int, input().split())
num_map = [None for _ in range(N)]
for _ in range(M):
    s, c = map(int, input().split())
    s -= 1
    if s > N or (num_map[s] is not None and num_map[s] != c) or (s == 0 and c == 0 and N > 1):
        print(-1)
        sys.exit()
    num_map[s] = c
num_map.reverse()

ans = 0
for i, num in enumerate(num_map):
    if num is not None:
        ans += num*(10**i)
    elif i == N-1 and N > 1:
        ans += (10**i)
print(ans)
n, m = map(int, input().split())
a = [-1]*n
for i in range(m):
    s, c = map(int, input().split())
    if a[s-1] == -1:
        a[s-1] = c
    elif a[s-1] != c:
        print(-1)
        exit()
    if n != 1 and s == 1 and c == 0:
        print(-1)
        exit()
for i in range(n):
    if a[i] == -1:
        a[i] = 0
if n != 1 and a[0] == 0:
    a[0] = 1
for i in range(n):
    print(a[i], end="")
import sys
n, m = map(int, input().split())
s = []
c = []
for i in range(m):
    _s, _c = map(int, input().split())
    s.append(_s)
    c.append(_c)

for i in range(1000):
    flag = True
    if len(str(i)) != n:
        continue
    for j in range(m):
        p = s[j]
        if str(c[j]) != str(i)[p-1]:
            flag = False
    if flag:
        print(i)
        sys.exit(0)

print(-1)
import sys
n,m=map(int,input().split())
d=dict()
if n==1 and m==0:
  print("0")
  sys.exit()
l=[-1]*n
for _ in range(m):
  s,c=map(int,input().split())
  s-=1
  if (s in d.keys() and d[s]!=c) or s>=n:
    print("-1")
    sys.exit()
  d[s]=c
  l[s]=c
if l[0]==0 and n>1:
  print("-1")
  sys.exit()
for i in range(n):
  if i==0 and l[0]==-1:
    l[0]=1
  else:
    if l[i]!=-1:
      continue
    else:
      l[i]=0
print(*l,sep='')
n, m = map(int, input().split())

num = [0] * n
flag = 1
if m == 0:
    if n == 1:
        print(0)
        exit()
num[0] = 1
for i in range(m):
    s, c = map(int, input().split())
    if num[s - 1] == 0 or (s - 1 == 0 and num[0] == 1):
        num[s - 1] = c
    else:
        if num[s - 1] != c:
            flag = 0
    
if flag == 0 or (n != 1 and num[0] == 0):
    print(-1)
else:
    for i in range(n):
        print(num[i], end="")
n,m = map(int, input().split())
scl = []
for _ in range(m):
    s,c = map(int, input().split())
    scl.append((s,c))

for i in range(0, 1000):
    si = str(i)
    if len(si) != n: continue
    for sc in scl:
        s,c = sc
        if si[s-1] != str(c):
            break
    else:
        print(i)
        exit()
else:
    print(-1)
n, m = map(int, input().split())
nums = [list(map(int, input().split())) for _ in range(m)]

for i in range(1000):
  is_ok = True
  num_str = str(i)
  if len(num_str) != n:
    continue
  for s, c in nums:
    if num_str[s-1] != str(c):
      is_ok = False
      break
  if is_ok:
    print(num_str)
    exit(0)
print(-1)
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

if n == 1:
    num_list = list(range(10))
else:
    num_list = list(range(10**(n-1), 10**n))
        
for i in num_list:
    flg = True
    for s, c in sc:
        if str(i)[s-1] != str(c):
            flg = False
            break
    if flg:
        print(i)
        exit()
print(-1)
N,M=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(M)]

for x in range(0, 1000):
    nx=x//10
    d=[x%10]
    while(nx):
        d.append(nx%10)
        nx//=10

    d.reverse()

    if len(d)!=N: continue

    chk=True
    for i in range(M):
        if(d[arr[i][0]-1]!=arr[i][1]): chk=False
    if chk: print(x);exit()

print(-1)
#! env/bin/local python3
# -*- coding: utf-8 -*-

n, m = map(int, input().split())
conditions = []
while True:
    try:
        conditions.append(list(map(int, input().split())))
    except EOFError:
        break

for i in range(0, 10**n):
    if len(str(i)) != n:
        continue
    flag = True
    for c in conditions:
        if str(i)[c[0]-1] != str(c[1]):
            flag = False

    if flag:
        print(i)
        break
else:
    print(-1)
ranges = [range(10), range(10, 100), range(100, 1000)]

N, M = map(int, input().split())
s = [0 for i in range(M)]
c = [0 for i in range(M)]
for i in range(M):
    s[i], c[i] = map(int, input().split())

ans = 0
found = False
for candidate in ranges[N - 1]:
    valid = True
    for i in range(M):
        if not (str(candidate)[s[i] - 1] == str(c[i])):
            valid = False
            break
    if valid:
        print(candidate)
        found = True
        break
if not found:
    print(-1)
N, M = map(int, input().split())

ans = [-1] * N

for _ in range(M):
    s, i = map(int, input().split())
    s -= 1
    if ans[s] != -1 and ans[s] != i:
        print(-1)
        exit()
    ans[s] = i

if N > 1 and ans[0] == -1:
    ans[0] = 1

for i in range(N):
    if ans[i] == -1:
        ans[i] = 0

ans = int(''.join(map(str, ans)))

if len(str(ans)) != N:
    print(-1)
    exit()

print(ans)
# -*- coding: utf-8 -*-
# 157c
n, m = map(int, input().split())
s = []
c = []
for _ in range(m):
  _s, _c = input().split()
  s.append(int(_s))
  c.append(_c)

ret = -1
for i in range(1000):
  x = str(i)
  if len(x) != n:
    continue
  isOk = True
  for _s, _c in zip(s, c):
    #if len(x) < _s or x[_s - 1] != _c:
    if x[_s - 1] != _c:
      isOk = False
      break
  if isOk:
    ret = i
    break
print(ret)
n, m = map(int,input().split())
sc = []
for i in range(m):
    s,c = map(int,input().split())
    sc.append([s,c])
for i in range(1000):
    if len(str(i)) == n:
        flag = True
        for j in range(m):
            if int(str(i)[sc[j][0] - 1]) != sc[j][1]:
                flag = False
        if flag:
            print(i)
            exit()
        else:
            continue
print(-1)
N ,M = map(int, input().split())

s = [0] * M
c = [0] * M

for i in range(M):
    s[i], c[i] = map(int, input().split())

for i in range(1000):
    x = str(i)
    count = 0
    if len(x) != N:
        continue
    for j in range(M):
        if x[s[j]-1] == str(c[j]):
            count += 1
    if count == M:
        print(x)
        break
else: 
    print(-1)
N, M = map(int, input().split())
s = []
c = []
for m in range(M):
    si, ci = map(int, input().split())
    s.append(si)
    c.append(ci)

ss = 10 ** (N - 1)
if N == 1:
    ss -= 1

for i in range(ss, 10 ** N):
    for m in range(M):
        if str(i)[s[m] - 1] != str(c[m]):
            break
    else:
        print(i)
        exit()

print(-1)
N,M = map(int,input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
dic = {}
if sc == [] and N == 1:
  print(0)
  exit()
if sc == [[1,0]] and N == 1:
  print(0)
  exit()
for k in sc:
  if k[0] in dic:
    if dic[k[0]] != k[1]:
      print(-1)
      exit()
  else:
    dic[k[0]] = k[1]
ans = 0
if 1 in dic and dic[1] == 0:
  print(-1)
  exit()
for k in dic:
  ans += 10**(N-k) * dic[k]
if ans < 10**(N-1):
  ans += 10**(N-1)
print(ans)
n, m = [int(i) for i in input().split(" ")]
sc = []
for i in range(m):
  sc.append([int(j) for j in input().split(" ")])

for i in range(10**(n-1) if n > 1 else 0, 10**(n), 1):
  f = True
  for con in sc:
    if str(i)[con[0]-1] != str(con[1]):
      f = False
  if f :
    print(i)
    break
else:
  print(-1)
n, m = [int(i) for i in input().split()]
n_list = [10] * n
for _ in range(m):
  si, ci = [int(i) for i in input().split()]
  if n_list[si - 1] == 10:
    n_list[si - 1] = ci
  elif n_list[si - 1] != ci:
    print(-1)
    exit()
if n != 1:
  ans = n_list[0] if n_list[0] != 10 else 1
else:
  ans = n_list[0] if n_list[0] != 10 else 0
if ans == 0 and n != 1:
  print(-1)
  exit()
for ai in n_list[1:]:
  if ai != 10:
    ans = ans * 10 + ai
  else:
    ans = ans * 10
print(ans)