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

if M == 0:
  if N == 1:
    print(0)
    sys.exit()
  elif N == 2:
    print(10)
    sys.exit()
  elif N == 3:
    print(100)
    sys.exit()
    
elif N == 1:
  S = [0]
elif N > 1:
  S = [1]+[0]*(N-1)
 
list = []
for i in range(M):
  a,b=input().split()
  list.append((int(a), int(b)))
 
for i in range(M):
  for j in range(M):
    if i != j and list[i][0] == list[j][0] and list[i][1] != list[j][1]:
      print(-1)
      sys.exit()
  
for i in range(M):
  s = list[i][0]
  c = list[i][1]
  if s == 1 and c == 0:
    print(-1)
    sys.exit()
  else:
    S[s-1] = c
  
SS = [str(i) for i in S]
 
SSS = ''.join(SS)
 
print(SSS)
      
    
  

