n,m=map(int,input().split())
data=[0]*n
for i in range(m):
    s,c=map(int,input().split())
    data[s-1]=c
if data[0]==0:
    print(-1)
else:
    ans=0
    for i in range(n):
        ans+=data[i]*10**(n-i-1)
    print(ans)