n , m  = map(int, input().split())
s = []
c = []
ans = [str(0) for _ in range(n)]

for _  in range(m):
  st, ct = map(int, input().split())
  if(ans[st-1] != "0"):
     print(-1)
     quit()
  ans[st-1] = str(ct)
ans = "".join(ans)
if len(str(int(ans))) < n:
  print(-1)
else:
  print(ans)
