n,m = map(int, input().split())
sc = [-1]*n
ans = 0
for i in range(m):
    s,c = map(int, input().split())
    if sc[s-1]==-1:
        sc[s-1]=c
    else:
        if sc[s-1]!=c: ans = -1

if m==0:
    if n==1: print(0)
    else: print('1'+'0'*(n-1))
elif ans==-1 or sc[0]==0:
    print(-1)
else:
    if sc[0]==-1:sc[0]=1
    for i in range(n):
        if sc[i]==-1: sc[i]=0
    ans = ''.join([str(n) for n in sc])
    print(ans)
