n, m = map(int, input().split())
ans = {}
for _ in range(m):
  s, c = map(int, input().split())
  if s-1 in ans and ans[s-1] != c:
    print(-1)
    quit()
  ans[s-1] = c
  
for i in range(n):
  if i not in ans:
    ans[i] = 0
if ans[0] == 0 and n>1:
  ans[0] = 1
  
a = ""
for i in range(n):
  a += str(ans[i])
print(a)