n, m = [int(w) for w in input().split()]
digit = [-1]*n
d = dict()
check = True
for i in range(m):
    s, c = [int(w) for w in input().split()]
    s -= 1

    if digit[s] == -1:
        digit[s] = c
    elif digit[s] == c:
        pass
    else:
        check = False
        break

if digit[0] == 0 and n > 2:
    check = False

if check:
    ans = ""
    for i, di in enumerate(digit):
        if di == -1:
            if i == 0:
                ans += "1"
            else:
                ans += "0"
        else:
            ans += str(di)
    if ans == "1":
        ans = 0
    print(ans)
else:
    print(-1)
