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

if n == 1 and m == 0:
  print(0)
  
for i in range(m):
  s,c = list(map(int,input().split()))
  if ans[s-1] != -1 and ans[s-1] != c:
    print(-1)
    exit()
  
  else:
    ans[s-1] = c
  
if ans[0] == 0 and n >= 2:
  print(-1)
  exit()
  
elif ans[0] == -1:
  ans[0] = 1
  
for i in range(n):
  if ans[i] == -1:
    ans[i] = 0
for i in range(n):
  ans[i] = str(ans[i])
  
print("".join(ans))
