peterverebics/CodeNet_Python_118 huggingface dataset:
N, M = map(int, input().split())
answer = [0 for _ in range(N)]

for _ in range(M):
    s, c = map(int, input().split())
    if answer[s-1] == 0:
        answer[s-1] = c
    else:
        if not answer[s-1] == c:
            print(-1)
            exit()

if answer[0] == 0:
    print(-1)
else:
    print("".join(list(map(str, answer))))
N,M=map(int,input().split())

sc = [list(map(int,input().split())) for _ in range(M)]
flag = 0
for i in range(M):
    if sc[i][0] ==N:
        flag=1
    else:
        continue
Nlist= [0]*N
ans=0
if flag == 0:
    print(-1)
else:
    for i in range(M):
        if (Nlist[sc[i][0]-1] == 1):
            continue
        else:
            Nlist[sc[i][0]-1]=1
            ans += pow(10,N-sc[i][0])*sc[i][1]
    print(ans)
import sys

N,M = map(int, input().split())
S = ["0"]*N
Table = [-1]*N

for _ in range(M):
    s,c = input().split()
    index = int(s)-1
    if Table[index]==-1:
        S[index]=c
        Table[index] = 0
    else:
        if int(S[index])>int(s):
            S[index]=c

if N==1:
    print(int(S[0]))
    sys.exit()

if S[0]!="0":
    s = ""
    for i in range(N):
        s = s + S[i]
    print(int(s))
    sys.exit()

print(-1)
N,M=list(map(int,input().split()))
ans_str='0'*N
flg=0
for i in range(M):
  a,b=list(map(int,input().split()))
  if(ans_str[a-1]!='0' and ans_str[a-1]!=str(b)):
    print(-1)
    flg=1
    break
  ans_str=ans_str[:a-1]+str(b)+ans_str[a:]
ans_int=int(ans_str)
if(flg==0):
  if(len(str(ans_int))==N):
    print(ans_int)
  else:
    print(-1)
n,m=map(int,input().split())
a=[[int(i) for i in input().split()] for l in range(m)]
b=[int(-1) for _ in range(n)]
for x in a:
    if b[x[0]-1]==-1:b[x[0]-1]=x[1]
    elif x[1]!=b[x[0]-1]:
        print(-1)
        exit(0)
if b[0]==0:
    print(-1)
    exit(0)
if b[0]==-1:b[0]=1
for i in range(1,n):
    if b[i]==-1:b[i]=0
print("".join(map(str,b)))
n,m=map(int,input().split())
ans = [None]*n
for _ in range(m):
    s,c = map(int,input().split())
    if n > 1 and s==1 and c==0:
        ans = [-1]
        break
    
    if ans[s-1] is None or ans[s-1] == c:
        ans[s-1] = c
    else:
        ans = [-1]
        break
else:
    for i in range(n):
        if ans[i] is None:
            ans[i] = 0 if i>0 else 1
        
print("".join(map(str,ans)))
def lstToInt(l,x=0):
  if len(l) == 0:
    return x
  else:
    return lstToInt(l[1:], x*10 + l[0])

n,m = map(int,input().split())
c = [-1]*n

for i in range(m):
  s, num = map(int,input().split())
  if c[s-1] != -1 and c[s-1] != num:
    print(-1)
    exit()
  elif s == 1 and num == 0 and n != 1:
    print(-1)
    exit()
  else:
    c[s-1] = num

if c[0] == 0:
  print(0)
  exit()

ans = lstToInt(list(0 if c[i] == -1 else c[i] for i in range(n)))
print(ans)
N, M = map(int, input().split())
ans='100'
chk=[False]*N

for m in range(M):
  s, c = input().split()
  s=int(s)
  if s==1 and c=='0':
    print(-1)
    exit(0)
  if chk[s-1] and c!=ans[s-1]:
    print(-1)
    exit(0)
  chk[s-1]=True
  ans = ans[:s-1] + c + ans[s:]
  #print(chk, ans)
print(ans)
n, m = map(int, input().split())
a = list([-1] * n)
p = list([False] * n)

for _ in range(m):
  s, c = map(int, input().split())
  if n > 1 and s == 1 and c == 0:
    print('-1')
    exit()
  if a[s-1] == -1:
    a[s-1] = c
  elif a[s-1] > c:
    a[s-1] = c

for i in range(n):
  if a[i-1] == -1:
    a[i-1] = 0
a = ''.join(map(str, a))

if len(str(int(a))) != n:
  print('-1')
else:
  print(int(a))
l=[10]*3
n,m=map(int,input().split())
for i in range(m):
  s,c=map(int,input().split())
  if c==0:continue
  if c<l[s-1]:
    l[s-1]=c
for i in range(len(l)):
  if l[i]==10:
    l[i]=str(0)
  else:
    l[i]=str(l[i])
ans=int("".join(l))
if ans==0 and n==1:
  print(1)
  exit(0)
if len(str(ans))!=n:
  print(-1)
else:
  print(ans)
n, m = map(int, input().split())
s_list, c_list = [], []
for _ in range(m):
    s, c = map(int, input().split())
    s_list.append(s)
    c_list.append(str(c))

ans = []
for _ in range(n):
    ans.append('0')

for s, c in zip(s_list, c_list):
    if ans[s-1] == '0':
        ans[s-1] = c
    elif ans[s-1] == c:
        pass
    else:
        print(-1)
        exit()

int_ans = int(''.join(ans))
if len(list(str(int_ans))) == n:
    print(int_ans)
else:
    print(-1)
n,m = map(int,input().split())

l = [-1]*(n+1)

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

if n != 1 and l[1] == 0:
  print(-1)
  exit()
if l[1] == -1:
  l[1] = 1
for i in range(2,n+1):
  if l[i] == -1:
    l[i] = 0
ls = list(map(str,l))
print(int(''.join(ls[1:])))
n, m = [int(i) for i in input().split()]
res = [-1 for _ in range(n)]
for _ in range(m):
  a, b = [int(i) for i in input().split()]
  if res[a-1] >= 0 and res[a-1] != b:
    print(-1)
    exit()
  elif a == 1 and b == 0:
    print(-1)
    exit()
  res[a-1] = b
if res[0] == -1:
  res[0] = 1
for i in range(1,n):
  if res[i] == -1:
    res[i] = 0
print(''.join([str(r) for r in res]))
S = []
N,M = [int(i) for i in input().split(" ")]

for  _ in range(M):
    S.append([int(i) for i in input().split(" ")])


flag = False
ans = []
for i in range(1,999):
    for s in S:
        try:   
            if [int(str(i)[s[0]-1]) == s[1] for s in S].count(True) == M:
                ans.append(i)
                flag = True
        except:
            pass

if flag:
    print(min(ans))
else:
    print("-1")
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(m)]
ans=[-1]*(n)
flag=True

for i in sc:
  if ans[i[0]-1]==-1:
    ans[i[0]-1]=i[1]
  elif ans[i[0]-1]!=-1 and ans[i[0]-1]!=i[1]:
    flag=False
    break
for i in range(n):
  if i==0 and ans[i]==-1:
    ans[i]=1
  elif ans[i]==-1:
    ans[i]=0
if flag and ans[0]!=0:
  print("".join(map(str,ans)))
else:
  print(-1)
n, m = map(int, input().split())
s, c = [], []
for _ in range(m):
    _s, _c = map(int, input().split())
    s.append(_s-1)
    c.append(_c)

ans = [0]*n
for i in range(m):
    if c[i] > ans[s[i]]:
        ans[s[i]] = c[i]

ans = int("".join(map(str, ans)))
print(-1 if len(str(ans)) != n else ans)
from collections import defaultdict

n, m = map(int, input().split())
sc = [map(int, input().split()) for _ in range(m)]

number = defaultdict(int)
for s, c in sc:
    if s in number and c != number[s]:
        print(-1)
        exit()
    number[s] = c

res = 0
for i in range(n):
    res += number[i + 1] * 10 ** (n - i - 1)

if res < 10 ** (n - 1):
    print(-1)
else:
    print(res)
N,M = map(int,input().split())
keep_value = [None]*N
check = False
for i in range(M):
    s,c = map(int,input().split())
    if((keep_value[s-1]!=None) and (keep_value[s-1]!=c)):
        print('-1')
        exit()
    else:
        keep_value[s-1]=c
if(None not in keep_value):
    print(''.join(map(str,keep_value)))
else:
    if(N>2 and keep_value[0]==0):
        print('-1')
    else:
        keep_value=[0 if i==None else i for i in keep_value]
        print(int(''.join(map(str,keep_value))))
n, m =map(int,input().split())
s = []
c = []
for _ in range(m):
  S, C =map(int,input().split())
  s.append(S)
  c.append(C)
for i in range(10**(n-1),(10**n)+1):
  l = str(i)
  if all( [ l[s[j]-1] == str(c[j]) for j in range(m)]):
    print(i)
    break
else:
  print("-1")
n,m = map(int,input().split())
sc = [input() for _ in range(m)]
ans = -1

for i in range(10**(n-1),10**n):
    i = str(i)
    ok = 0
    
    for j in sc:
        s,c = j.split()
        
        if i[int(s)-1] == c:
            ok += 1
        
    if ok == m:
        ans = int(i)
        break
        
print(ans)
n, m = map(int, input().split())

sc = [list(map(int, input().split())) for _ in range(m)]

lst = [[-1] for _ in range(n)]

for i in sc:
    lst[i[0] -1].append(i[1])

ans = ''

for i in lst:
    if len(set(i)) == 2:
        ans += str(i[1])
    elif len(set(i)) == 1:
        ans += '0'
    else:
        print(-1)
        exit()

if ans[0] != '0':
    print(ans)
else:
    print(-1)
N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(M)]

res = []
for i in range(10**(N-1), 10**N):
    nm = str(i)
    is_n = True
    for s, c in A:
        if not nm[s-1] == str(c):
            is_n = False
            break
    if is_n:
        res.append(i)

if res:
    print(min(res))
else:
    print(-1)
N,M = map(int,input().split())

li = [list(map(int,input().split())) for i in range(M)]

for i in range(10**(N-1),10**N):
    num = str(i)
    for o  in li:
        s,c = o
        if not num[s-1]==str(c):

            break

    else:
        print(i)
        exit()


print(-1)
import sys
n,m=map(int,input().split())
if n==3:
  ans=["1","0","0"]
elif n==2:
  ans=["1","0"]
else:
  ans=["1"]
cnt=[0,0,0]
for i in range(m):
  s,c=map(int,input().split())
  if s==1 and c==0:
    print(-1)
    sys.exit()
  elif ans[s-1]!=str(c):
    if cnt[s-1]==0:
      ans[s-1]=str(c)
      cnt[s-1]=1
    else:
      print(-1)
      sys.exit()
print("".join(ans))
N, M = map(int, input().split())
ans = ["#" for _ in range(N)]
for i in range(M):
    s, c = map(int, input().split())
    if ans[s - 1] == "#" or ans[s - 1] == c:
        ans[s - 1] = c
    else:
        print(-1)
        exit()
for i in range(N):
    if ans[i] == "#":
        if i == 0:
            ans[i] = "1"
        else:
            ans[i] = "0"
if N != 1 and ans[0] == 0:
    print(-1)
else:
    print("".join(map(str, ans)))
n, m = map(int, input().split())
scs = [list(map(int, input().split())) for _ in range(m)]
ans = ['0'] * n
jdgmt = 0
for i in range(m):
    if ans[scs[i][0] - 1] == '0' or ans[scs[i][0] - 1] == str(scs[i][1]):
        ans[scs[i][0] - 1] = str(scs[i][1])
    else:
        jdgmt = -1
if jdgmt == -1 or ans[0] == '0':
    print(-1)
else:
    print(''.join(ans))
N, M = map(int, input().split())
num = [0 for i in range(N)]

for i in range(M):
    s, c = map(int, input().split())
    if num[s-1] == 0 or num[s-1] == c:
        num[s-1] = c
    else:
        print(-1)
        exit()

if num[0] == 0:
    print(-1)
    exit()
else:
    for j in range(N):
        print(num[j], end="")
c=-1
d=0
f=0
g=0
N, M = map(int, input().split())
list = []
for i in range(M):
    a,b=input().split()
    list.append((int(a), int(b)))

for i in range(M):
	if list[i][0]>N:
		print(c)
		f=1
		break
	for j in range(i+1,M):
		if list[i][0]==list[j][0]:
			g=1
			if list[i][1]!=list[j][1]:
				print(c)
				f=1
				break
	if f==1:
		break
	if g==0:
		d+=list[i][1]*(10**(M-list[i][0]))
	g=0
if f==0:
	print(d)
n,m = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(m)]
anslist = []
for i in range(10**n):
  for j in range(len(sc)):
    k = sc[j][0]
    if len(str(i)) != n or str(i)[k-1] != str(sc[j][1]):
      break
  else:
    anslist.append(i)
if anslist:
  if anslist[0] == 0 and n != 1:
    print(-1)
  else:print(anslist[0])
else:print(-1)
N,M = list(map(int,input().split()))
A = ['0']*N
for i in range(M):
  s,c = list(map(int,input().split()))
  if A[s-1] != '0' and A[s-1] != str(c):
    print('-1')
    exit()
  else:
    A[s-1] = str(c)
if len(A) != 1 and A[0] == '0':
    print('-1')
    exit()
print(''.join(A))
n,m = map(int,input().split())

l = [-1]*(n+1)

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

for i in range(1,n+1):
  if l[i] == -1:
    l[i] = 0
ls = list(map(str,l))
print(int(''.join(ls[1:])))
import sys
N,M = map(int,input().split())
s = [list(map(int,input().split())) for i in range(M)]
ans = 0
ans_list = [ 0 for i in range(N)]

if M == 0:
    if N == 1:
        print('0')
    else:
        print('-1')
    sys.exit()

for i in range(M):
    ans_list[s[i][0]-1] = s[i][1]

for i in range(N):
    ans = ans * 10 + ans_list[i]

if len(str(ans)) == N:
    print(ans)
else:
    print('-1')
def resolve():
    N, M = list(map(int, input().split()))
    SC = [list(map(int, input().split())) for _ in range(M)]
    value = [None for _ in range(N)]
    for s, c in SC:
        value[s-1] = c
    for i in range(N):
        if i == 0 and (value[i] is None or value[i] == 0):
            print(-1)
            return
        if value[i] is None:
            value[i] = 0
    print("".join(map(str, value)))


if '__main__' == __name__:
    resolve()
S=[];C=[]
N,M=map(int,input().split())
for i in range(M):
  s,c=map(int,input().split())
  S.append(s)
  C.append(c)
#print(S)
#print(C)
A=[0]*N
for i in range(M):
  A[S[i]-1]=C[i]
if N==3:
  B=A[0]*100+A[1]*10+A[2]
elif N==2:
  B=A[0]*10+A[1]
elif N==1:
  B=A[0]
if len(str(B))!=N:
  print(-1)
else:
  print(B)
N, M = map(int, input().split())
lst = [0, 0, 0]
k = 1

for i in range(M):
    s, c = map(int, input().split())
    if lst[s-1] != c and lst[s-1] != 0:
        k = 0

    else:
        lst[s-1] = c

ans = lst[:N]

if k or (N == 1 and ans[0] == 0):
    print(''.join(map(str,ans)))

else:
    print(-1)
n, m = map(int,input().split())
s = [list(map(int,input().split())) for _ in range(m)]
s.sort(key=lambda x: x[0])
if m == 0:
    print(0)
    quit()
for i in range(1,1000):
    num = str(i)
    count = 0
    if s[-1][0] > len(num):
        continue
    for j in range(m):
        if num[s[j][0]-1] == str(s[j][1]):
            count += 1
        else:
            break
    if n == count:
        print(num)
        quit()
print(-1)
n, m = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(m)]
lis = [str(0)]*n
for i in s:
    lis[int(i[0]) - 1] = str(i[-1])

lis = int("".join(lis))
if lis == 0 or len(str(lis)) != n:
    print(-1)
else:
    print(lis)
N,M=map(int,input().split())
SC=[input().split() for _ in range(M)]
ans=["0"]*N
for s,c in SC:
  if ans[int(s)-1]!="0" and ans[int(s)-1]!=c:
    print(-1)
    exit()
  if int(s)==1 and int(c)==0:
    print(-1)
    exit()
  ans[int(s)-1]=c
if N>1 and ans[0]=="0":
  ans[0]="1"
print("".join(ans))
n,m = map(int, input().split())
a = [-1 for i in range(n)]
for i in range(m):
    s,c = map(int, input().split())
    s -= 1
    if a[s] != -1 and c != a[s]:
        print(-1)
        exit()
    a[s] = c

if a[0] == -1:
    a[0] = 1
for i in range(1, n):
    if a[i] == -1:
        a[i] = 0
ans = 0
for i in a:
    ans = ans * 10 + i
print(ans if len(str(ans)) == n else -1 )
n, m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]

sc.sort(key=lambda x: x[0])

num = [0]*n
check = [False] * n
for i in range(m):
    if check[sc[i][0]-1] and num[sc[i][0]-1] != sc[i][1]:
        print(-1)
        quit()
    if num[sc[i][0]-1] == 0:
        num[sc[i][0]-1] = sc[i][1]
        check[sc[i][0]-1] = True
ans = ''
for i in range(n):
    ans += str(num[i])

if ans[0] != '0':
    print(ans)
else:
    print(-1)
n, m = map(int, input().split())
sc = []
flag = False
ans = ''

for _ in range(m):
    s, c = map(int, input().split())
    sc.append([s, c])

for i in range(1, 1000):
    i = str(i)
    if len(i)<n:
        continue

    for s, c in sc:
        if i[s-1]==str(c):
            flag = True
        else:
            flag = False
            break

    if flag:
        ans = i
        break

if ans:
    print(int(ans))
else:
    print(-1)
N, M = map(int, input().split())
s = []
c = []
for i in range(M):
    si, ci = map(int, input().split())
    s.append(si)
    c.append(ci)
s_true = [j for j, k in enumerate(s) if k <= N]
s = [s[l] for l in s_true]
c = [c[m] for m in s_true]
ans_list = [0] * N
ans = ""
if M == 0:
    print("-1")
    exit()
else:
    for n in range(len(s)):
        ans_list[s[n] - 1] = c[n]
if ans_list[0] == 0 and N != 1:
    print("-1")
else:
    for a in ans_list:
        ans += str(a)
    print(ans)
N,M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
x = [-1]*N
for s,c in sc:
    s -= 1
    if x[s] == -1 or x[s] == c:
        x[s] = c
    else:
        print(-1)
        quit()
if N!=1 and x[0]==0:
    print(-1)
    quit()
if x[0]==-1:
    x[0]=0
if N>=2 and x[1]==-1:
    x[1]=0
if N==3 and x[2]==-1:
    x[2]=0
print(int(''.join(list(map(str,x)))))
import sys

N, M = map(int, input().split())
if M == 0:
  print('0')
  sys.exit()

ans = 0
d={}

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

if ans == -1:
  print(ans)
else:
  for i in range(N):
    if i+1 in d:
      print(d[i+1], end='')
    elif i+1 == 1:
      print('1', end='')
    else:
      print('0', end='')
n, m = list(map(int, input().split()))
ans = [0,0,0]
for i in range(m):
  s,c = list(map(int, input().split()))
  if ans[s-1] == c or ans[s-1] == 0:
    ans[s-1] = c
  else:
    print(-1)
    break
while ans[0] == 0 and len(ans) != 1:
  ans = ans[1:]
if len(ans) == n: 
  print(''.join([str(i) for i in ans]))
else:
  print(-1)
N, M = map(int, input().split())
sc = []

def check(num, sc):
  ret = True
  snum = format(num,'03d')
  for tmp in sc:
    s = tmp[0]
    c = tmp[1]
    
    if snum[s-1] != str(c):
      ret = False
  if snum[0] == "0":
    ret = False
  return(ret)

for i in range(M):
  sc.append(list(map(int,input().split())))
  
ret = -1
for num in range(1000):
  if check(num, sc):
    ret = num
    break

print(ret)
N,M = [int(i) for i in input().split()]
d = {}
for i in range(M):
    s,c = [int(i) for i in input().split()]
    if d.get(s,c) != c:
        print(-1)
        break
    else:
        d[s] = c
else:
    if d.get(1,1) == 0:
        print(-1)
    else:
        l = [str(d.get(1,1))]
        l+=[str(d.get(i,0)) for i in range(2, N+1)]
        print(''.join(l))
n, m = map(int, input().split())
res = ['0' for _ in range(n)]
for _ in range(m):
    s, c = map(int, input().split())
    if (s == 1 and c == 0) or (res[s-1] != '0' and res[s-1] != str(c)):
        print(-1)
        exit()
    else:
        res[s-1] = str(c)
if res[0] == '0':
    res[0] = '1'
print(''.join(res))
n,m=map(int,input().split())

result="*"*n

for _ in range(m):
    s,c=map(int,input().split())
    if result[s-1]=="*":
        result=result[:s-1]+str(c)+result[s:]
        #print(result)
    elif result[s-1]!=str(c):
        print(-1)
        exit()

if result[0]=="0":
    print(-1)
    exit()
result2=result.replace("*","0")

result2=int(result2)
result2=str(result2)


if len(result2)==n:
    print(int(result2))
else:
    temp=10**(n-1)
    print(int(result2)+temp)
n,m = map(int,input().split())
maxn = 10**n
a=[0 for i in range(m)]
b=[0 for i in range(m)]
for i in range(m):
    a[i],b[i] = map(int,input().split())

for i in range(maxn//10, maxn):
    tmp = str(i)
    ok = True
    for aa, bb in zip(a,b):
        if int(tmp[aa-1]) == bb:
            pass
        else:
            ok = False
            break
    if ok:
        print(i)
        break
else:
    print(-1)
def main():
    N,M = map(int, input().split())
    m = ["0"]*N
    for _ in range(M):
        s,c = input().split()
        # 左からsけた目がc
        m[N-int(s)] = c
    if N==1:
        print("".join(m[::-1]))
    else:
        if m[0]=="0":
            print("-1")
        else:
            print("".join(m[::-1]))

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

a = [list(map(int, input().split())) for _ in range(m)]

ans = [0 for _ in range(n)]
check = [False for _ in range(n)]

flag = 0

for i, j in a:
    if check[i-1] == 0 or ans[i-1] == j:
        ans[i-1] = j
        check[i-1] = True
    else:
        flag = 1
       
c = ""
for k in ans:
    c+=str(k)

if flag == 1 or len(str(int(c))) != n:
    print(-1)
else:
    
    print(c)
import math
n,m=map(int,input().split())
arr=[None]*n
flag=True
for i in range(m):
	s,c=map(int,input().split())
	s-=1
	if arr[s]==None:
		arr[s]=c 
	else:
		if arr[s]!=c:
			flag=False
		else:
			continue 
if arr[0]==None:
	arr[0]=1
if arr[0]==0 and n!=1:
	print(-1)
	exit()
if flag:
	for i in arr:
		if i==None:
			print(0,end="")
		else:
			print(i,end="")
	print()
else:
	print(-1)
n,m=map(int, input().split())
l = [None]*n
msg=''
for _ in range(m):
    s, c = input().split()
    index = int(s)-1
    if l[index] is None:
        l[index] = c
    else:
        if l[index] == c:
            continue
        else:
            msg=-1
            break
l = list(map(lambda x: '0' if x is None else x, l))
if msg == -1:
    print(msg)
elif l[0] == '0' and len(l) >1:
    print(-1)
else:
    print(msg.join(l))
N,M=map(int,input().split())
n=['0']*N
a=0
for i in range(M):
    s,c=map(str,input().split())
    if n[int(s)-1]!='0' and n[int(s)-1]!=c:
        a=1
    if s=='1' and c=='0':
        a=1
    n[int(s)-1]=c
if n[0]=='0':
    n[0]='1'
if a==0:
    print(''.join(n))
else:
    print(-1)
N, M = map(int, input().split())
res = ["*"]*N
flag = True
for i in range(M):
    s, c = input().split()
    if s == "1" and c == "0":
        if N != 1:
            flag = False
    if res[int(s)-1] != "*" and res[int(s)-1] != c:
        flag = False
    res[int(s)-1] = c

if flag:
    if res[0] == "*":
        res[0] = "1"
    print("".join(x if x != "*" else "0" for x in res))
else:
    print(-1)
N,M= map(int,input().split())
R = []
for _ in range(M):
    R.append(tuple(input().split()))
for n in range(10**(N-1), 10**N):
    isa = True
    for (s,c) in R:
        if str(n)[int(s)-1] != c:
            isa = False
    if isa:
        print(n)
        exit()
print(-1)
n, m = map(int, input().split())

result = []
for _ in range(n):
  result.append(-1)

for _ in range(m):
  s, c = map(int, input().split())
  if result[s-1] not in [-1, c]:
    print(-1)
    exit()
  elif s == 1 and c == 0:
    print(-1)
    exit()
  else:
    result[s-1] = c

for _ in range(len(result)):
  if result[_] == -1:
    result[_] = 0
    
if result[0] == 0:
  result[0] = 1
  
result = map(str, result)
result = "".join(result)
  
print(result)
# coding: utf-8
# Your code here!
N,M=map(int,input().split())

l=[]
for _ in range(M):
   s,t=map(int,input().split())
   l.append([s,t])

for i in range(10**(N-1),10**N):
    #print(i)
    temp=list(str(i))
    judge=True
    for s,t in l:
        if temp[N-s]!=str(t):
            judge=False
    if judge:
        print(i)
        exit()

print(-1)
n, m = map(int, input().split())
ans = [0]*n
ans_list = []

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

if n == 1:
  L=[str(a) for a in ans]
  print("".join(L))
  exit()

ans_list.sort()
if n >= 2:
  for ans in ans_list:
    if ans[0] != 0:
      L=[str(a) for a in ans]
      print("".join(L))
      exit()

print(-1)
import sys
 
N, M = map(int, input().split())
SC = [list(map(int, input().split())) for _ in range(M)]
 
flagN = [False]*N
numN = [0]*N
numN[0] = 1
 
for sc in SC:
  s, c = sc[0], sc[1]
  if flagN[s-1] == False:
    flagN[s-1] = True
    numN[s-1] = c
  elif numN[s-1] == c:
    continue
  else:
    print(-1)
    sys.exit()
    
if N != 1 and numN[0] == 0:
  print(-1)
  sys.exit()

ans = ''
for n in numN:
  ans += str(n)
print(ans)
import sys
# スペース区切りの整数入力
N,M = map(int, input().split())

sc = {}
snum = '0' * N

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

for i in sc:
    snum = snum[:i-1] + str(sc[i]) + snum[i:] 

if N == len(str(int(snum))):
    print(snum)
else:
    print(-1)
N, M = map(int, input().split())
ans = ['0']*N
for i in range(M):
  s, c = input().split()
  if (ans[int(s)-1] != '0' and ans[int(s)-1] != c) or (N>1 and(s,c) == ('1','0')):
    ans = -1
    break
  ans[int(s)-1] = c
if ans == -1:
  print(-1)
else:
  print(int(''.join(ans)))
n, m = [int(i) for i in input().split(' ')]
sc = [[int(i) for i in input().split(' ')] for j in range(m)]
sc = list(map(list, set(map(tuple, sc))))

s = [i[0] for i in sc]
c = [i[1] for i in sc]

fl1 = len(set(s)) != len(s)
fl2 = 0 in c
if fl1 | fl2:
  print('-1')
else:
  ans = ['0' for i in range(n)]
  if 1 not in s:
    ans[0] = '1'
  for i in sc:
    ans[i[0]-1] = str(i[1])
  print(''.join(ans))
N, M = map(int, input().split())
S = [0]*N
for _ in range(M):
  s, c = map(int, input().split())
  if S[s-1] == c:
    continue
  elif S[s-1] == 0:
    S[s-1] = c
  elif S[s-1] != c:
    print(-1)
    exit()

if S[0] == 0 and len(S)==1:
  print(0)
  exit()
elif S[0] == 0:
  print(-1)
  exit()
print(''.join(map(str, (S))))