N, M = map(int, input().split())
ans = [-1] * (N+1)
Flag = True

for i in range(M):
  s, c = map(int, input().split())
  if ans[s-1] < 0:
    ans[s-1] = c
  elif ans[s-1] == c:
    continue
  else:
    Flag = False

if N > 1 and ans[0] == 0:
  Flag = False

for i in range(N):
  if ans[i] == -1:
    if ans[i+1] == 0:
      ans[i] = 1
    else:
      ans[i] = 0

ans = ans[:N]

if Flag:
  print(int("".join([str(i) for i in ans])))
else:
  print(-1)