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