n,m = map(int, input().split(' '))
b = [list(map(int, input().split(' '))) for _ in range(m)]
for i in range(10**(n-1),10**n):
    x = list(str(i))
    for s,c in b:
        if x[s-1] != str(c):
            break
    else:
        print(int(''.join(x)))
        break
else:
    print(-1)