import sys
   
N, M = map(int, input().split())
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()
    
      
if M > N:
  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)
