N, M = map(int, input().split())
sc = [tuple(map(int, input().split())) for _ in range(M)]
def cands(N):
    if N ==1:
        return range(10)
    else:
        return range(10 ** (N-1), 10 **N)

def main(N, sc):
    nums = cands(N)
    print(nums)
    for n in nums:
        try:
            for s,c in sc:
                assert(int(str(n)[s-1]) == c)
        except AssertionError as e:
            continue
        return n
    else:
        return -1
print(main(N, sc))