n, m = map(int, input().split())
SC = [list(map(int, input().split())) for _ in range(m)]
ans = ["*"] * n
for i, j in SC:
  if ans[i - 1] == "*":
    ans[i - 1] = j
  elif ans[i - 1] != j:
    print(-1)
    exit()
if n != 1 and ans[0] == 0:
  print(-1)
  exit()
for i in range(n):
  if i == 0 and ans[i] == "*":
    ans[i] = 1
  elif i != 0 and ans[i] == "*":
    ans[i] = 0
ans = "".join(map(str, ans))
print(ans)