n,m=[int(x) for x in input().rstrip().split()]
flag = 1
l=[-1 for i in range(n)]
for i in range(m):
    s,c = [int(x) for x in input().rstrip().split()]
    if l[s-1]==-1 or l[s-1]==c:
        l[s-1]=c
    else:
        flag =0
        break
        

ans = ""
if flag == 0 or (n!=1 and l[0]==0):
    print(-1)
else:
    for i in range(len(l)):
        if l[i]==-1:
            if i==0:
                ans+=str(1)
            else:
                ans+=str(0)
        else:
            ans+=str(l[i])
    print(ans)










