n, m = map(int, input().split())
sc_ls = [list(map(int, input().split())) for _ in range(m)]

for num in range(10**n):
    if len(str(num)) != n:
        continue

    for s, c in sc_ls:
        if str(num)[s-1] != str(c):
            break
    else:
        print(num)
        break
else:
    print(-1)