n,m = map(int, input().split())
ls = [list(map(int, input().split())) for i in range(m)]

ans=[-1]*n
flag=True
for s,c in ls:
    if s==1:
        if c==0 or not(ans[s-1]==c or ans[s-1]==-1):
            flag=False
            break
        else:
            ans[s-1]=c
    else:
        if not(ans[s-1]==c or ans[s-1]==-1):
            flag=False
            break
        else:
            ans[s-1]=c

for i in range(n):
    if ans[i]==-1:
        ans[i]=0
        if i==0:
            ans[0]=1

if flag:
    print(''.join(map(str,ans)))
else:
    print(-1)



