def f():
    N, M = map(int, input().split(" "))
    S = {}
    for _ in range(M):
        s, c = map(int, input().split(" "))
        if S.get(s) is not None and S.get(s) != c:
            
            return -1
        S[s] = min([S.get(s, 10000), c])

    min_digit = min(S.keys())
    if S[min_digit] == 0:
        if min_digit == 0:
            return 0
        else:
            return -1

    l = []
    for i in range(N):
        if i < min_digit:
            default = 1
        else:
            default = 0
        l.append(str(S.get(i + 1, default)))

    return "".join(l)

print(f())