N,M=map(int,input().split())
s=[0]*M
c=[0]*M
for i in range(0,M):
  s[i],c[i]=map(int,input().split())

flag=0
data=[-1 for i in range(0,N)]
for i in range(0,M):
  if data[s[i]-1]==-1:
    data[s[i]-1]=c[i]
  else:
    if data[s[i]-1]!=c[i]:
      flag=1
if data[0]==0:
  flag=1
if flag==1:
  print(-1)
else:
  for i in range(0,N):
    if data[i]==-1:
      if i==0:
        data[i]=1
      else:
        data[i]=0
  ans=''
  for i in range(0,M):
    ans+=str(data[i])
  print(ans)
