N, M = map(int,input().split())
answer = [-1]*N
ae = 0
  

for i in range(M):
  s,c = map(int,input().split())
  if answer[-s] == -1:
    answer[-s] = c
  elif answer[-s] != -1 and answer[-s] != c:
    print(-1)
    ae = 1
    break
for i in range(N):
  if answer[i] == -1:
    if i == 0 and N > 1:
      answer[i] = 1
    else:
      answer[i] = 0
if ae == 0 and answer[N-1] == 0 and N != 1:
  print(-1)
  ae = 1
elif ae == 0:
  for i in range(N):
    print(answer[-(i+1)],end='')
  