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

for i in range(1000):
    i=str(i)
    if len(i)!=n:
        continue
    for x,y in lis:
        if i[x-1]!=str(y):
            break
    else:
        print(i)
        exit()
print(-1)