N,M=map(int,input().split())

ans=[-1]*N
for _ in range(M):
  s,c=map(int,input().split())
  if ans[s-1]!=c and ans[s-1]!=-1:
    print(-1)
    exit()
  ans[s-1]=c

if ans[0]==0:
  if N!=1:
    print(-1)
    exit()
if ans[0]==-1:
  ans[0]=1
for i in range(1,N):
  if ans[i]==-1:
    ans[i]=0

print(int("".join(map(str,ans))))