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

for i in range(10**(n-1),10**n):
    i=str(i)
    for s,c in sc:
        if i[s-1] != str(c):
            break
    else:
        print(i)
        break
print(-1)