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

flag=True
ex=[False]*(N)
for i in range(M):
    S,C=map(int,input().split())
    if S>N:
        flag=False
        break
    elif ex[S-1]==False or ex[S-1]==str(C):
        ex[S-1]=str(C)
    else:
        flag=False
        break

if N>1 and ex[N-1]==0:
    flag=False

if flag:
    for i in range(N):
        if (i<N-1 or N==1) and ex[i]==False:
            ex[i]='0'
        elif i==N-1 and ex[i]==False:
            ex[i]='1'
    Ex=''.join(ex)
    print(Ex)
else:
    print(-1)