import sys
n,m=map(int,input().split())
d=dict()
l=[-1]*n
for _ in range(m):
  s,c=map(int,input().split())
  s-=1
  if (s in d.keys() and d[s]!=c) or s>=n:
    print("-1")
    sys.exit()
  d[s]=c
  l[s]=c
if l[0]==0:
  print("-1")
  sys.exit()
for i in range(len(l)):
  if i==0 and l[0]==-1:
    l[0]=1
  else:
    if l[i]!=-1:
      continue
    else:
      l[i]=0
print(*l,sep='')



