N,M=map(int,input().split())
ret = [-1]*(N+1)
fg = True
for i in range(M):
  s,c=map(int,input().split())
  if s==1 and c==0:
    fg = False
    break
  elif ret[s]==-1:
    ret[s]=c
  elif ret[s]!=c:
    fg = False
    break
if fg:
  ret = ret[1:]
  for i in range(N):
    if ret[i]==-1:
      if i==0:
        ret[i]=1
      else:
        ret[i]=0
  print(''.join(map(str,ret)))
else:
  print(-1)