from sys import exit
N, M = map(int, input().split())
ans = ["a" for i in range(N)]
if M == 0:
  print(10 ** (N - 1))
  exit()
for i in range(M):
  s, c = map(int, input().split())
  if ans[s - 1] == "a":
    ans[s - 1] = str(c)
  elif ans[s - 1] != str(c):
    print(-1)
    exit()
if ans[0] == "a":
  ans[0] = "1"
if ans[0] == "0":
  print(-1)
  exit()
ans = [a.replace("a", "0") for a in ans]
ans = int("".join(ans))
print(ans if 10 ** N > ans >= 10 ** (N - 1) else -1)