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