n, m = map(int, input().split())
ans = [1] + [0] * (n - 1)
for i in range(m):
    s, c = map(int, input().split())
    if s == 1:
        if c == 0:
            print("-1")
            exit()
        else:
            ans[0] = c
    elif ans[s - 1] != 0 and ans[s - 1] != c:
        print("-1")
        exit()
    ans[s - 1] = c
print(*ans, sep = "")