n,m=map(int,input().split())
placelist=[]
numlist=[]
ans=-1
for _ in range(m):
    place,num=map(int,input().split())
    placelist.append(place)
    numlist.append(num)
for i in range(10**(n-1),10**n):
    cnt=0
    tmp=str(i)
    for j in range(m):
        if tmp[placelist[j]-1]==str(numlist[j]):
            cnt+=1
    if cnt==m:
        ans=tmp
        break
print(ans)