n,m = map(int,input().split())
n_li=[list(map(int,input().split())) for i in range(m)]

ans_num = ["x"]*n
ans = "Y"
for i in n_li:
    if i[0] == 1 and i[1] == 0:
        ans = "N"
if ans == "Y":
    for i in n_li:
        if ans_num[i[0]-1] == "x" or ans_num[i[0]-1] == i[1]:
            ans_num[i[0]-1] = i[1]
        elif ans_num[i[0]-1] != i[1]:
            ans = "N"
if ans == "Y":
    for j in range(len(ans_num)):
        if ans_num[j] == "x":
            if j == 0:
                ans_num[j] = 1
            else:
                ans_num[j] = 0
    print(*ans_num,sep="")
else:
    print(-1)