n , m  = map(int, input().split())
s = []
c = []
ans = [str(0) for _ in range(n)]
b = [0 for _ in range(n)]
ans[0] = "1"
for _  in range(m):
  st, ct = map(int, input().split())

  if(b[st-1] == 0 or ans[st-1] == str(ct)):
    ans[st-1] = str(ct)
    b[st-1] = 1
  else:
    print(-1)
    quit()
ans = "".join(ans)
if len(str(int(ans))) < n:
  print(-1)
else:
  print(ans)