N,M = map(int,input().split())
A = ['a']*N
dic = {} 
for _ in range(M):
  s,c = map(int,input().split())
  if s in dic and dic[s] != c:
    print(-1)
    exit()
  elif s==1 and c == 0:
    print(-1)
    exit()
  else:
    dic[s] = c
  ans = ''
  for i in range(N):
    if i+1 in dic:
      ans += str(dic[i+1])
    elif i+1 == 1:
      ans += '1'
    else:
      ans += '0'
print(ans)