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

ans = ["1"] + ["0"] * (N - 1)
default = "1" + "0" * (N - 1)

for i in range(M):
  s,c = input().split()
  s = int(s) - 1
  if N > 1 and s == 0 and c == "0":
    print(-1)
    exit(0)
  if ans[s] == default[s] or ans[s] == c:
    ans[s] = c
  else:
    print(-1)
    exit(0)
     
print("".join(ans))