N,M=map(int,input().split())
s=[0 for i in range(M)]
c=[0 for i in range(M)]
for i in range(M):
    s[i],c[i]=map(int,input().split())
    s[i]-=1
for n in range(10**(N-1),10**N):
    t=str(n)
    flag=1
    for i in range(M):
        if t[s[i]]!=str(c[i]):
            flag=0
            break
    if flag==1:
        print(n)
        exit()
print(-1)
