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

ans = [-1]*n
c1 = [-2]*n

an1 = 1
for s,c in sc:
    if s == 1 and c == 0:
        an1 = -1
        break
    else:
        if c1[s-1] > -2 and ans[s-1] != c:
            an1 = -1
            break
        else:
            c1[s - 1] += 1
            ans[s - 1] = c

if an1 == 1:
    for i,n1 in enumerate(ans):
        if n1 == -1:
            if i == 0:
                ans[i] = 1
            else:
                ans[i] = 0
    print("".join(list(map(str, ans))))
else:
    print(an1)