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

for i in range(10**(n-1),10**n):
    s=str(i)
    for x,y in a:
        if s[x-1]!=str(y):
            break
    else:
        print(i)
        exit()
print(-1)