n,m=map(int,input().split())
a=[]
for _ in range(m):
    s,c=map(int,input().split())
    a.append((s-1,c))
for i in range(1,1001):
    r=str(i)
    j=1
    if len(r)==n:
        for idx,char in a:
            if r[idx]!=str(char):
                j=0
                break
        if j:
            print(r)
            exit()
print(-1)
            