dig, cnt = map(int, input().split())
ans = [-1]*dig

for i in range(cnt):
  place, num = map(int, input().split())
  place -= 1
  if ans[place] != -1:
    if ans[place] != num:
      print(-1)
      exit()
  elif place == 0 and num == 0:
    print(-1)
    exit()
  else:
    ans[place] = num
    
for i in range(cnt):
  if ans[i] == -1:
    if i == 0:
      ans[i] = 1
    elif ans[i] == -1:
      ans[i] = 0
  print(ans[i], end="")