n,m=map(int,input().split())
k=[list(map(int,input().split()))for i in range(m)]
a=[1]+[0]*(n-1)
for i in k:
    if not (i[0]-1==i[1]==0):
        a[i[0]-1]=i[1]
l=1
for i in k:
    if a[i[0]-1]!=i[1]:
        l=0
if l:
    print("".join([str(i)for i in a]))
else:
    print(-1)