n,m=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(m)]

s=sorted(s)

a=[0]*n
for i in range(m):
    a[s[i][0]-1]=s[i][1]


if a[0]==0:
    print(-1)
else:
    b=""
    for i in range(n):
        b+=str(a[i])
    print(b)