N, M = map(int, input().split())

num = [-1] * N
for _ in range(M):
  s, c = map(int, input().split())
  s -= 1
  if s == 0 and c == 0:
    print(-1)
    exit(0)
  if num[s] != -1 and c != num[s]:
    print(-1)
    exit(0)
  num[s] = c

ans = ""
for i in range(N):
  if num[i] == -1:
    if i == 0:
      ans += str(1)
    else:
      ans += str(0)
  else:
    ans += str(num[i])

print(ans)
