N,M = map(int,input().split())
SC = [tuple(map(int,input().split())) for i in range(M)]

if N==1:
    r = range(10)
elif N==2:
    r = range(10,100)
else:
    r = range(100,1000)
for n in r:
    print(n)
    n = str(n)
    for s,c in SC:
       #print("s=",s,"c",c)
        if n[s-1] != str(c):
            break
    else:
        print(n)
        exit()
print(-1)
