peterverebics/CodeNet_Python_118 huggingface dataset:
n, m = map(int, input().split())

ans = [-1] * n


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

    else:
        ans[s] = c

if ans[0] == 0 and n >= 2:
    print(-1)
    exit()

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

a = ""
for i in ans:
    a += str(i) if i != -1 else "0"
print(a)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n,m = map(int,input().split())
d = {}
invalid = False
for _ in range(m):
    s,c = map(int,input().split())
    if s == 1 and c == 0:
        invalid = True
    if s in d.keys():
        if d[s] != c:
            invalid = True
    else:
        d[s] = c

if invalid:
    print (-1)
    exit ()

for i in range(1,n+1):
    if i in d.keys():
        print (d[i],end="")
    else:
        print (1,end="") if i == 1 else print (0,end="")
print ()
n,m = map(int,input().split())
s = []
c = []
for i in range(m):
    val1,val2 = map(int,input().split())
    s.append(val1)
    c.append(val2)

for i in range(1000):
    if len(str(i)) == n:
        flg = True
        for j in range(m):
            if int(str(i)[j-1]) != c[j]:
                    flg = False
        if flg:
            print(i)
            break
if not flg:
    print(-1)
N,M = map(int,input().split())
ans = [0]*N
for i in range(M):
    s,c = map(int,input().split())
    ans[s-1] = c
if ans[0] == 0:
    if len(ans) != 1:
        print(-1)
        exit()
print("".join([str(i) for i in ans]))
n, m = map(int, input().split())

tmp = ["0" for i in range(n)]
for i in range(m):
  s, c= map(str, input().split())
  if int(tmp[int(s)-1]) >= int(c) or int(tmp[int(s)-1]) == 0:
    tmp[int(s)-1] = c

ans = int("".join(tmp))
if len(str(ans)) == n:
  print(ans)
else:
  print(-1)
n,m=list(map(int,input().split()))
a=[-1]*n
flg=0
for i in range(m):
    s,c=list(map(int,input().split()))
    if a[s-1]!=-1 and a[s-1]!=c:
        flg=1
    a[s-1]=c

if (flg==1):
    print("-1")
    exit()

if a[n-1]==-1:
    print("-1")
    exit()


for i in range(n):
    if a[i]==-1:
        a[i]=0

b="".join(map(str,a))
print(int(b))
N, M = map(int, input().split())
res = ["?" for _ in range(N)]


for _ in range(M):
    s, c = map(int, input().split())
    if res[s - 1] == "?" or res[s - 1] == str(c):
        res[s - 1] = str(c)
    else:
        print(-1)
        exit()

if res[0] == "0" and N != 1:
    print(-1)
    exit()

if res[0] == "?":
    res[0] = "1"

for i in range(len(res)):
    if res[i] == "?":
        res[i] = "0"

print(int("".join(res)))
n,m = map(int,input().split())
ans = [0 for _ in range(n)]

z = 0
for _ in range(m):
  s,c = map(int,input().split())
  done = []
  if not s in done:
    ans[s-1] = c
    done.append(s)
  else:
    if ans[s-1] != c:
      print(-1)
      z = 1
      break
      
if n != 1 and ans[0] == 0:
  print(-1)
else:
  ans = map(str,ans)
  if z ==0:
    print(int(''.join(ans)))
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]

ok = False
n = [-1] * N
for s, c in sc:
  if n[s-1] != -1:
    if n[s-1] == c: continue
    ans = -1
    ok = True
    break
  n[s-1] = c

if n[0] == 0 and N > 1:
  ans = -1
  ok = True
if not ok:
  ans = ""
  for i in range(N):
    if i == 0 and n[i] == -1:
      ans += "1"
    elif n[i] == -1:
      ans += "0"
    else:
      ans += str(n[i])
print(ans)
import collections as cl
N, M = map(int, input().split())
dic = cl.defaultdict(lambda:-1)
num = 0
for i in range(0, M):
    s, c = map(int, input().split())
    if N - s in dic and dic[N-s] != c:
        print(-1)
        exit(0)
    else:
        dic[N-s] = c
if dic[N-1] == -1:
    dic[N-1] = 1
for j in dic.keys():
    num += dic[j] * (10 ** j)
if num < 10 ** (N - 1):
    print(-1)
else:
    print(num)
n,m = map(int,input().split())
t = [0 for i in range(n)]
b = ""
a = True
for i in range(m):
    s,c = map(int,input().split())
    if t[s-1] == 0 or t[s-1] == c:
        t[s-1] = c
    else:
        a=False
for i in range(n):
    b += str(t[i])
if n > 1 and b[0] == '0':
    print(-1)
elif b[0] == '0':
    print(0)
elif a:
    print(b)
else:
    print(-1)
N, M = map(int, input().split())
ans = ['-1'] * N

for i in range(M):
    s, c = map(int, input().split())
    if ans[s-1] == str(c):
        continue
    elif ans[s-1] == '-1':
        ans[s-1] = str(c)
    else:
        ans = -1
        print(ans)
        exit()

if N >= 2 and ans[0] == '0':
    ans = -1
    print(ans)
    exit()
elif ans[0] == '-1':
    ans[0] = '1'

ans = ''.join(ans).replace('-1', '0')

print(ans)
import sys

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

num=["0"]*n

for i in range(m):
  s,c=map(int,input().split())
  
  if num[s-1]!="0":
    if num[s-1]==str(c):
      continue
    
    else:
      print(-1)
      sys.exit()
    
  else:
    num[s-1]=str(c)
  
if n==1:
  print(''.join(num))
  sys.exit()
  
if num[0]=="0":
  print(-1)
  
else:
  print(''.join(num))
N, M = map(int, input().split())
ans='1' + '0'*(N-1) if M>1 else '0'
chk=[False]*N

for m in range(M):
  s, c = input().split()
  s=int(s)
  if s==1 and c=='0' and N>1:
    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)
import sys
n,m = map(int, input().split())

p = [0]*n
q = [False]*n
for i in range(m):
  s,c = map(int, input().split())
  if s == 1 and c == 0:
    continue
  if q[s-1] == False:
    p[s-1] = c
    q[s-1] = True
  elif p[s-1] > c:
    p[s-1] = c

t = ''
for i in p:
  t += str(i)
  
t = int(t)
if len(str(t)) == n:
  print(t)
else:
  print(-1)
N, M = map(int, input().split())
ans = [-1] * N
for _ in range(M):
    i, n = map(int, input().split())
    if ans[i-1] == -1 or ans[i-1] == n:
        ans[i-1] = n
    else:
        print(-1)
        exit()
ans = [n if n != -1 else 0 for n in ans]
if ans[0] == 0 and len(ans) > 1:
    ans[0] = 1
print(*ans, sep='')
import numpy as np 

N, M = map(int, input().split())

data = np.array([-1 for i in range(N)])

error = 0

for i in range(M):
	x, y = map(int, input().split())
	if data[x-1] != y and data[x-1] >= 0:
		error = 1
	else:
		data[x-1] = y

if error != 1:
	for i in range(N):
		if data[i] == -1:
			data[i] = 0

if error == 1 or (data[0] == 0 and len(data) != 1):
	print(-1)
else:
	L=[str(a) for a in data]
	L="".join(L)
	print(L)
N,M = map(int, input().split())
L = [-1]*N
ans = 0
for _ in range(M):
    s,c = map(int, input().split())
    if ans < 0:
        continue
    if L[s-1] >= 0 and L[s-1] != c:
        ans = -1
        continue
    if N > 1 and s == 1 and c == 0:
        ans = -1
        continue
    if L[s-1] == c:
        continue
    ans += c*10**(N-s)
    L[s-1] = c
print(ans)
n, m = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(m)]
lis = [str(0)]*n
for i in s:
    if lis[int(i[0]) - 1] != 0:
        print(-1)
        exit()
    else:
        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())
s = []
c = []
ans = [0 for _ in range(n)]
has_num = [False for _ in range(n)]

for i in range(m):
    S, C = map(int, input().split())
    s.append(S)
    c.append(C)

    if has_num[S - 1] == True and ans[S-1] != C:
        print(-1)
        exit(0)
    has_num[S-1] = True

    ans[S - 1] = C

if ans[0] == 0 and n != 1 and m != 0:
    print(-1)
    exit(0)

if m == 0 and n != 1:
    ans[0] = 1

maped_ans = map(str, ans)
print(''.join(maped_ans))
n, m = list(map(int, input().split()))

s = [0] * m
c = [0] * m

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

result = [0] * n

for i in range(m):
    if result[s[i]-1] == 0:
      result[s[i]-1] = c[i]
    elif result[s[i]-1] > c[i]:
      result[s[i]-1] = c[i]

print(result)
if result[0] == 0:
    print(-1)
    exit()

ans = "".join(str(x) for x in result)
print(ans)
#C

n,m = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]
s = [l[i][0] for i in range(m)]
c = [l[i][1] for i in range(m)]

t = True
a = [0] * n

for i in range(m):
    if a[s[i]-1] == 0 or a[s[i]-1] == c[i]:
        a[s[i]-1] = c[i]
    else:
        t = False
        break
        
#print(a)
if n != 1 and a[0] == 0:
    t = False
if t:
    print("".join(map(str,a)))
else:
    print("-1")
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] != -1:
    if a[s-1] != c:
      print(-1)
      exit()
for i in range(len(a)):
  if a[i] == -1:
    a[i] = 0
if len(a) != 1 and a[0] == -1:
  a[0] = 1
elif len(a) != 1 and a[0] == 0:
  print(-1)
  exit()
print("".join(map(str,a)))
N, M = list(map(int, input().split()))
nums = [list(map(int, input().split())) for i in range(M)]
if [1, 0] in nums:
  print('-1')
  quit()
dic = {}

for (s, c) in nums:
  if s in dic and dic[s] != c:
    print('-1')
    quit()
  else:
    dic[s] = c

total = 10**(N-1)    
for key in sorted(dic.keys()):
    if key == 1:
   		total = 10**(N-key)*dic[key]
    else:
        total += 10**(N-key)*dic[key]
print(total)
import numpy as np
N, M = map(int, input().split())
A = np.zeros([N, 2], dtype = np.int)
A[0, 0] = 1
for i in range(M):
    s, c = map(int, input().split())
    if s == 1 and c == 0:
        print('-1')
        exit()
    if A[s - 1, 1] == 0:
        A[s - 1, 0] = c
        A[s - 1, 1] = 1
    elif A[s - 1, 1] == 1 and A[s - 1, 0] == c:
        continue
    else:
        print('-1')
        exit()
else:
    print(*A[:, 0], sep='')
N, M = map(int, input().split())
if N < M:
  print(-1)
  exit()
SC = [list(map(int, input().split())) for _ in range(M)]
SC = list(map(list, set(map(tuple, SC))))
num = ['0'] * N
pre = 0
for sc in SC:
  if sc[0] == pre:
    print(-1)
    exit()
  num[sc[0] - 1] = str(sc[1])
  pre = sc[0]
if num[0] == '0' and N > 1:
  print(-1)
  exit()
integer = "".join(num)
if len(integer) == N:
  print(int(integer))
else:
  print(-1)
import sys
input_line = [int(i) for i in input().split(" ")]
n = input_line[0]
m = input_line[1]

ans = ["0"] * n
for i in range(m):
    input_line = input().split(" ")
    if ans[int(input_line[0]) - 1] == "0" or ans[int(input_line[0]) - 1] == input_line[1]:
        ans[int(input_line[0]) - 1] = input_line[1]
    else:
        print(-1)
        sys.exit()

ans_num = int("".join(ans))
if n == len(str(ans_num)):
    print(ans_num)
else:
    print(-1)
n,m = map(int,input().split())
digit = [0]*(m)
value = [0]*(m)
for i in range(m):
    digit[i],value[i] = map(int,input().split())

#全探索
ans = 0
keta = 10**(n-1)
for i in range(keta, 10**5):
    s = str(i)
    flag = True
    for j in range(m): 
        if int(s[digit[j]-1]) != value[j]: #違ったらFalse
            flag = False
    if flag:
        ans = i
        break
print(ans if flag else '-1')
n,m = map(int, input().split(' '))
b = [list(map(int, input().split(' '))) for _ in range(m)]
for i in range(10**(n-1),10**n):
    x = list(str(i))
    for s,c in b:
        if x[s-1] != str(c):
            break
    else:
        print(int(''.join(x)))
        break
else:
    print(-1)
n, m = map(int, input().split())

sc = []
flag = 1

for i in range(m):
  if flag != 1:
    break
  s, c = map(int, input().split())
  for x in sc:
    if s == x[0] and c != x[1]:
      print(-1)
      flag = 0
      break
  sc.append((s,c))
  
if flag == 1 and (1, 0) in sc:
  print(-1)
  flag = 0
            
sc = list(set(sc))
ans = 0

for x in sc:
  ans += x[1] * 10 ** (n - x[0])
  
if flag == 1 and ans < 10 ** (n-1):
  print(ans + 10 ** (n-1))
elif flag == 1:
  print(ans)
n,m = map(int,input().split())
digit = [[] for _ in range(n+1)]
for _ in range(m):
    s,c = map(int,input().split())
    digit[s].append(c)
ret = ''
for d in digit[1:]:
    if len(set(d))>=2:
        print(-1)
        exit()
    elif len(set(d))==1:
        ret += str(d[0])
    else:
        ret += '0'
print(ret if ret[0]!='0' else -1)
N , M = input().split()
M = int(M)
N = int(N)
ans = ['0' for i in range (N)]
fl = True

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

res = ''

if (ans[0] == '0' and N != 1) :
    ans[0] = '1'

for i in ans :
    res += i

print (res if fl else -1)
n,m=map(int, input().split())
alist=[list(map(int, input().split())) for i in range(m)]
ans=-1
for i in range(10**n-1,10**(n-1),-1):
  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)
n,m = map(int,input().split())
ans = []
for i in range(n):
    ans.append(0)
for k in range(m):
    s,c = map(int,input().split())
    if c == 0:
        c = 10    
    if ans[s-1] == 0 or ans[s-1] == c:
        ans[s-1] = c
    else:
        print('-1')
        exit()
if ans[0] == 10:
    print('-1')
    exit()
ans = [str(s) for s in ans]
print(ans)
if ans[0] == "0":
    ans[0] = "1"
ans = [s.replace("10","0") for s in ans]
print("".join(ans))
n,m=map(int,input().split())
a = [-1]*(n+1)

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

if a[1] == 0:
  if n>1:
    print(-1)
    exit()
  else:
    print(ans)
else:
  ans = max(1, a[1])
  for i in range(2, n+1):
    ans = ans*10+max(0, a[i])
print(ans)
N, M = map(int, input().split())
s = [list(map(int, list(input().split()))) for i in range(M)]

ans = [-1] * N
for i in s:
    if ans[i[0] - 1] != -1 and ans[i[0] - 1] != i[1]:
        print(-1)
        exit()
    ans[i[0] - 1] = i[1]

ans = [int(str(a).replace('-1', '0')) for a in ans]
res = ''.join((map(str, ans)))
if int(res) > 0 and len(str(int(res))) == N:
    print(int(res))
else:
    print(-1)
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

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

ans = [0] * n
for i in range(m):
    k = n - v[i][0]
    ans[k] = v[i][1]

num = 0
for i in range(n - 1, -1, -1):
    num += ans[i] * 10**i

if len(str(num)) != n:
    print(-1)
else:
    print(num)
#graph implementation
import math
n,m=map(int,input().split())
ans=[0]*n
for i in range(m):
    s,c=map(int,input().split())
    ans[s-1]=c
if ans[0]==0:
    print(-1)
else:
    for i in ans:
        print(i,end="")
print()
n, m = map(int, input().split())
a = [0] * n
d = {}
ok = True
for i in range(m):
    s, c = map(int, input().split())
    if s not in d or d[s] == c:
        d[s] = c
        a[s - 1] = c
    else:
        ok = False
if ok == False or len(a) != 1 and a[0] == 0:
    print(-1)
else:
    print(*a, sep="")
stdin = open(0).read().split('\n')
N, M = map(int,stdin[0].split())
num=['a']*N
flag = True
for i in range(M):
    s, c = stdin[i+1].split()
    if not num[int(s)-1].isdecimal():
        num[int(s)-1]=c
    elif num[int(s)-1]!=c:
        flag = False
        break
ans = "".join(num).replace('a', '0')
print(int(ans) if ans[0]!='0' and flag else -1)
import math
def main():
    N, M = map(int, input().split())

    ans = {i:0 for i in range(N)}
    for _ in range(M):
        s, c = map(int, input().split())
        if s-1 not in ans:
            print(-1)
            return 0

        ans[s-1] = c
    if (ans[0] == 0) and (len(ans) != 1):
        print(-1)
        return 0

    for v in ans.values():
        print(v, end="")




    return 0
if __name__ == '__main__':
    main()
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
s = [0] * n
for i in sc:
    s[i[0]-1] = str(i[1])
ans = ""
cnt = True
for i in s:
    #print(i)
    if i == '0' and cnt and len(s) != 1:
        ans += str(1)
        cnt = False
    ans += str(i)
#print(ans)
if len(ans) != len(str(int(ans))):
    print(-1)
else:
    print(ans)
N, M = map(int, input().split())
sc_list = [list(map(int, input().split())) for _ in range(M)]

ans = ['*'] * N

for sc in sc_list:
    s, c = sc
    if s == 1 and c == 0:
        print('-1')
        exit()
    if ans[s - 1] != '*' and int(ans[s - 1]) != c:
        print('-1')
        exit()
    ans[s - 1] = str(c)


ans = ''.join(ans)
print(ans.replace('*', '0'))
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, M = map(int, input().split())
    sc = [tuple(map(int, input().split())) for _ in range(M)]

    for i in range(10 ** N):
        v = str(i)
        l = len(v)
        for s, c in sc:
            if s > l or int(v[s-1]) != c:
                break
        else:
            print(i)
            exit()
    print(-1)
    
if __name__ == '__main__':
    main()
N, M = map(int, input().split())
a = [[] for _ in range(N)]
for i in range(M):
  s, c = map(int, input().split())
  a[s-1].append(c)
flag = 0
ans = [0]*N
for i in range(len(a)):
  if len(set(a[i]))>1:
    flag = 1
    break
  elif a[i]:
    ans[i] = a[i][0]
if a[0]:
  if a[0][0] == 0:
    flag = 1
    
if flag == 0:
  if ans[0] == 0:
    ans[0] = 1
  ans = ''.join((str(n) for n in ans))
  print(int(ans))
else:
  print(-1)
import sys


def LI():
    return list(map(int, input().split()))


N, M = LI()
ans = [-1]*N
for _ in range(M):
    a, b = LI()
    if ans[a-1] == b or ans[a-1] == -1:
        ans[a-1] = b
    else:
        print(-1)
        sys.exit()
if ans[0] == -1:
    ans[0] = 1
if ans[0] == 0:
    print(-1)
    sys.exit()
S = ""
for i in range(N):
    if ans[i] == -1:
        ans[i] = 0
    S += str(ans[i])
print(S)
string = input().split(' ')
N = int(string[0])
M = int(string[1])

digit = [10] * N
ans = 0

for i in range(M):
  string = input().split(' ')
  s_new = int(string[0])
  c_new = int(string[1])
  if digit[s_new - 1] != c_new and digit[s_new - 1] != 10:
    ans = -1
    break
  else:
    digit[s_new - 1] = c_new


if ans == -1 or digit[0] == 10:
  print('-1')
else:
  for i in range(N):
    if digit[i] == 10:
      continue
    ans = ans + digit[i] * ( 10 ** (N - i -1))
   
  print(ans)
N,M=map(int,input().split())
n=['0']*N
for i in range(M):
    s,c=map(str,input().split())
    if n[int(s)-1]!='0' and n[int(s)-1]!=c:
        print(-1)
        exit()
    if s=='1' and c=='0':
        print(-1)
        exit()
    n[int(s)-1]=c
if n[0]=='0':
    n[0]='1'
print(''.join(n))
n, m = map(int, input().split())
t = [-1] * n
for _ in range(m):
    s, c = map(int, input().split())
    s -= 1
    if t[s] != -1 and t[s] != c:
        print(-1)
        exit()
    t[s] = c

if n != 1:
    if t[0] == 0:
        print(-1)
        exit()
    

if t[0] == 0:
    t[0] = 1

for i in range(n):
    if t[i] == -1:
        t[i] = 0
    
print(''.join(map(str, t)))
N,M=map(int,input().split())
res=[0]*(N)
ans=[0]*(N)
for i in range(M):
    si,ci=map(int,input().split())
    si-=1
    if res[si]==1 and ans[si]!=ci:
        print(-1)
        exit()
    res[si]=1
    ans[si]=ci
if ans[N-1]==0:
    print(-1)
    exit()
ans = ans[::-1]
for s in ans:
    print(s, end ="")
n,m=map(int,input().split())
dic={}
for i in range(m):
  s,c=map(int,input().split())
  if s not in dic:
    if s==1 and c==0:
      print('-1')
      exit()
    else:
      dic[s]=c
  elif dic[s]==c:
    continue
  else:
    print('-1')
    exit()

for i in range(1,n+1):
  if i==1 and i not in dic:
    print('1',end="")
  elif i in dic:
    print(dic[i],end='')
  else:
    print('0',end='')
N,M = map(int,input().split())

A = [-1]*N

B = -1

for i in range(M):
  s,c = map(int,input().split())
  if A[s-1] == -1:
    A[s-1] = c
  else:
    if A[s-1] != c:
      B = 0
if B == 0 or (N != 1 and A[0] == 0) or (N ==1 and A[0] == -1):
  print(-1)
else:
  for i in range(len(A)):
    if A[i] == -1:
      A[i] = 0
  print(int("".join(map(str, A))))
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(M)]

keta = [0,0,0]
DP = [0,0,0]

for i in sc:
  s = i[0]-1
  c = i[1]
  if DP[s] == 0 or (DP[s] == 1 and keta[s] == c):
    keta[s] = c
    DP[s] = 1
  else:
    DP[s] = -1
    
if keta[-1*N] == 0:
  DP[-1*N] = -1
  
if -1 in DP:
  print(-1)
else:
  ans = ''
  for i in keta:
    ans += str(i)
  print(int(ans[3-N:]))
n, m = map(int, input().split())
if n == 1 and m == 0:
  print(0)
  exit()
  
answer = [-1]*n

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

if answer[0] == -1:
  answer[0] = 1
for j in range(n):
  if answer[j] == -1:
    answer[j] = 0
    
answer = [str(x) for x in answer] 

print(int(''.join(answer)))
N,M = list(map(int,input().split()))
S = []
C = []
ans = [0 for i in range(3)]
fr = 0
for i in range(M):
    s = 0
    c = 0
    s,c = list(map(int,input().split()))
    S.append(s)
    C.append(c)

for i in range(M):
    if C[i] == ans[S[i]-1] or ans[S[i]-1] == 0:
        ans[S[i]-1] = C[i]
    else:
        fr += 1
if fr != 0:
    print(-1)
else:
    print(ans[0]*100 + ans[1]*10 + ans[2])
n, m = [int(i) for i in input().split()]
s = []
c = []
for i in range(m):
    tmp = [int(j) for j in input().split()]
    s.append(tmp[0])
    c.append(tmp[1])

#for i in range(10 ** (n - 1) - int(n == 1) ,10 ** n):
for i in range(10 ** (n - 1),10 ** n):

    status = True
    for j in range(m):
        if(str(i)[s[j] - 1] != str(c[j])):
            status = False
    if(status):
        print(i)
        exit()
print(-1)
import sys

n, m = list(map(int, input().split()))
ar = [list(map(int, input().split())) for _ in range(m)]
ans = [0 for _ in range(n)]

for a in ar:
    if ans[a[0] - 1] != 0:
        print("-1")
        sys.exit()
    ans[a[0] - 1] = a[1]

if ans[0] == 0:
    ans[0] = 1

ans = int("".join(map(str, ans)))
n,m=map(int,input().split())
a=[9]*n
b=[True]*n
if(n==1 and m==0):
    print(0)
    exit()
if(n!=1 and m==0):
    print(-1)
    exit()
for i in range(m):
    s,c=map(int,input().split())
    b[s-1]=False
    if(a[s-1]>=c):a[s-1]=c
for i in range(n):
    if(b[i]):a[i]=0
ans=""
for i in a:
    ans+=str(i)
if(len(str(int(ans)))==n):print((int(ans)))
else:print(-1)
n, m = map(int, input().split())

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

for _ in range(m):
    s, c = map(int, input().split())
    s -= 1

    if n >= 2 and s == 0 and c == 0:
        print(-1)
        exit()
    elif  num[s] != -1 and num[s] != c:
        print(-1)
        exit()
    else:
        num[s] = c

if num[0] == -1:
    num[0] = 1

num = ["0" if n == -1 else str(n) for n in num]

print("".join(num))
n, m = [int(i) for i in input().split()]
sc = []
for i in range(m):
    sc.append([int(j) for j in input().split()])

c = list("0"*n)
c[0] = "1"
for i, j in sc:
    c[i-1] = str(j)

flag = True
for i, j in sc:
    if c[i-1] != str(j):
        print("-1")
        break
else:
    print("".join(c))
import sys

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

num = [[0] for i in range(n)]
s = []

test = list(list(map(int, input().split())) for i in range(m))

for i in test:
  num[i[0] - 1].append(i[1])

for i in range(len(num)):
  if(len(set(num[i])) >= 3):
    print(-1)
    sys.exit()
  elif(i == 0 and max(num[i]) == 0 and n != 1):
    print(-1)
    sys.exit()
  if(i == 0):
    num[0][0] = 1
  s.append(str(max(num[i])))

print(''.join(s))
n,m = map(int,input().split())
l = [-1]*n
for i in range(m):
    s,c = map(int,input().split())
    if l[s-1] == -1:
        l[s-1] = c
    elif l[s-1] != c:
        print('-1')
        exit()
if l[0] == 0:
    print('-1')
    exit()
if l[0] == -1:
    l[0] = 1
for i in range(1,n):
    if l[i] == -1:
        l[i] = 0
# print(l)
ans = 0
for i in range(n):
    ans += l[n-i-1]*10**i
print(ans)
N,M=map(int,input().split())
p=True
l=[-1 for _ in range(N)]
for i in range(M):
  s,c=map(int,input().split())
  if l[s-1] == -1:
    l[s-1] = c
  elif not l[s-1]==c:
    p=False
if p:
  ans=""
  if l[0]==0:
    p=False
  elif l[0]==-1:
    ans="1"
  else:
    ans=str(l[0])
  for i in l[1:]:
    if i == -1:
      ans+="0"
    else:
      ans+=str(i)
print(int(ans) if p else -1)
N, M = map(int, input().split())

ans = ['*'] * N
flag = 0
for i in range(M):
  s, c = map(int, input().split())
  if ans[s-1]=='*' or ans[s-1]==str(c):
    ans[s-1] = str(c)
  else:
    flag = 1
    break;

if flag == 0:
  num = ['0' if i == '*' else i for i in ans]
  an = ''.join(num)
  if N!=1 and an[0]=='0':
    flag = 1
  
if flag == 1:
  an = -1
  
print(int(an))