import numpy as np
 
n,m = map(int, input().split())
x = np.zeros(n)
ans = 0
 
for i in range(m):
  s,c = map(int, input().split())
  if x[s-1] == 0:
    x[s-1] = c
  elif x[s-1] != c:
    ans = -1

if ans == -1:
  print(ans)
elif x[0] == 0:
  print(-1)
else:
  str_ans = ""
  for i in range(n):
    str_ans = str_ans + str(int(x[i]))
  print(str_ans)