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

mm=10**(n-1)
mmm=10**n
for i in range(mm,mmm):
    ok=True
    ii=str(i)
    for j in sc:
        ss=j[0]-1
        cc=j[1]

        if ii[ss]==str(cc):
            pass
        else:
            ok=False
            break
    if ok:
        print(i)
        quit()
print(-1)