import sys
n,m=map(int,input().split())
sclist=[]
for i in range(m):
    sclist.append(list(map(int,input().split())))

for i in range(m):
    if sclist[i][0] == 1 and sclist[i][1] == 0:
        print(-1)
        sys.exit()
    for j in range(i+1,m):
        if sclist[i][0] == sclist[j][0] and sclist[i][1] != sclist[j][1]: 
            print(-1)
            sys.exit()
outlist=["0" for _ in range(n)]
outlist[0]="1"

for sc in sclist:
    outlist[sc[0]-1] = str(sc[1])

print("".join(outlist))

