n,m=[int(x) for x in input().rstrip().split()]
flag = 0
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:
        flag = 1
        break
    else:
        l[s-1]=c 

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










