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

ans  =  [-1] *  N
for i in range(M):
  s,c =  map(int, input().split())
  if ans[s-1] == -1:
    ans[s-1] = c
  elif ans[s-1] == c:
    continue
  else:
    ans = -1
    break

if ans == -1:
  print(ans)
elif ans[0] ==0:
  if N == 1:
    print(0)
  else:
    print(-1)
else:
  answer = ''
  for i in range(N):
    if ans[i] ==  -1:
      if i ==  0:
        ans[i] = 1
      else:
        ans[i]  = 0
    answer += str(ans[i])
  print(answer)