n,m=map(int,input().split())
t=[-1]*n
flag=0
for i in range(m):
  a,b=map(int,input().split())
  if t[a-1]==-1:
    t[a-1]=b
  elif t[a-1]!=b:
    flag=1
if flag==1:
  print(-1)
elif t[0]==0 and n==1:
  print(0)
elif t[0]==0:
  print(-1)
else:
  for j in range(len(t)):
    if t[j]==-1:
      if j==0:
        t[j]=1
      else:
        t[j]=0
  print(''.join(map(str,t)))