n, m = [int(x) for x in input().split()]
sc = [[int(x) for x in input().split()] for i in range(m)]
r = [-1] * n
def solution():
    for s, c in sc:
        if r[s - 1] >= 0 and r[s - 1] != c or (s == 1 and c == 0 and n != 1):
            return '-1'
        r[s - 1] = c
    for i in range(n):
        if r[i] < 0:
            if i == 0:
                r[i] = 1
            else:
                r[i] = 0
    return ''.join(str(r[i]) for i in range(n))

print(solution())