n,m = map(int,input().split())
l = [1] + [0]*(n-1)
check = set()
for i in range(m):
    s,c = map(int,input().split())
    if (s in check and l[s-1] != c) or (s==1 and c==0):
        l[0] = -1
        break
    check.add(s)
    l[s-1] = c
if l[0] == -1:
    print(l[0])
else:
    print(*l,sep="")