n,m = map(int, input().split())
ans = [10 for i in range(n)]
flag = 0
for i in range(m):
    s,c = map(int, input().split())
    if s==1 and c==0:
        flag = -1
    if ans[s-1]!=10 and ans[s-1]!=c:
        flag = -1
    ans[s-1] = c
#print(ans)
if ans[0]==10:
    ans[0]=1
    if n==2 or n==3:
        if ans[1]==10:
            ans[1]=1
            if n==3:
                if ans[2]==10:
                    ans[2]=1
for i in range(n):
    if ans[i]==10:
        ans[i]=0
map_ans = map(str, ans)
answer =''.join(map_ans)

print(-1 if flag==-1 else answer)