n,m = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]
z = 10**(n-1) if n!=1 else 0
for i in range(z,10**n):
    f = 1
    si = str(i)
    for s,c in l:
        if si[s-1] != str(c):
            f = 0
            break
    if f:
        print(i)
        exit()
print(-1)