N,M=map(int,input().split())
SC=[list(map(int,input().split())) for i in range(M)]
ans='0'*N
x=[]
for s,c in SC:
  if s==1 and c==0:
    print(-1)
    exit(0)
  if s not in x:
    ans=ans[:s-1]+str(c)+ans[s:]
    x.append(s)
  else:
    if ans[s-1]==str(c):
      continue
    else:
      print(-1)
      exit(0)
if ans[0]=='0' and N>1:
  ans='1'+ans[1:]
print(ans)