
N,M=map(int,input().split())
slist=[]
for i in range(M):
    slist.append(list(map(int,input().split())))
ans=["0"]*N


for i in range(len(slist)):
    print("i",i)
    if ans[slist[i][0]-1] == "0":
        ans[slist[i][0]-1] = slist[i][1]
    elif ans[slist[i][0]-1] != slist[i][1]:
        ans=["-1"]
        break

#print(ans)

if ans[0]=="0":
    ans[0]=1
if N>=2 and ans[0]==0:
    ans=["-1"]
    
for i in range(len(ans)):
    if ans[i]=="0":
        ans[i]=0

print(*ans,sep=(""))