N, M = map(int, input().split())
Z = [None for _ in range(N)]
for i in range(M):
  s, c = map(int, input().split())
  if Z[s-1] == None or Z[s-1] == c:
    Z[s-1] = c
  else:
    print(-1)
    break
else:
  if Z[0] == 0:
    print(-1)
  elif Z[0] == None:
    Z[0] = 1
    for l in range(N):
      if Z[l] == None:
        Z[l] = 0
    print("".join(map(str, Z)))