N, M = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(M)]

hantei = True
condition = [None] * (N+1)
condition[0] = 0
S = []
for s, c in data:
    if (condition[s] is None) or (condition[s] == c):
        condition[s] = c
        S.append(s)
    else:
        break
else:
    hantei = False

if (condition[1] == 0) or hantei:
    print(-1)
else:
    if None in condition:
        temp = list(set(range(1, N+1)) - set(S))
        for t in temp:
            if (N == 1) or (t != 1):
                condition[t] = 0
            else:
                condition[t] = 1
    condition = map(str, condition[1:])
    print("".join(condition))
