def solve(n, m, s, c):
    slot = [-1] * n
    for si, ci in zip(s, c):
        if (slot[si-1] != -1) and (slot[si-1] != ci):
            return -1
        slot[si-1] = ci
    if slot[0] == 0:
        return 0 if n == 1 else -1
    for i in range(n):
        if slot[i] == -1:
            slot[i] = int(i == 0)
    return "".join(map(str, slot))

n, m = map(int, input().split())
s = [0] * m
c = [0] * m
for i in range(m):
    s[i], c[i] = map(int, input().split())
print(solve(n, m, s, c))