N,M=map(int,input().split())
S=[]
C=[]
for i in range(M):
  s,c=map(int,input().split())
  S+=[s]
  C+=[c]
tf=1
ans=[]
for i in range(N):
  ans+=[-1]
for i in range(M):
  if ans[S[i]-1] ==-1:
    ans[S[i]-1]=C[i]
  else:
    if ans[S[i]-1]!=C[i]:
      tf=0
      break
    else:
      continue
for i in range(M):
  if ans[i]==-1:
    if i!=0:
      ans[i]=0
    else:
      ans[i]=1
if ans[0]==0:
  print('-1')
else:
  ansnum=''
  for i in range(M):
    ansnum+=str(ans[i])
  print(ansnum)