n,m=map(int,input().split())
ans = [None]*n
for _ in range(m):
    s,c = map(int,input().split())
    if s==1 and c==0:
        ans = [-1]
        break
    
    if ans[s-1] is None or ans[s-1] == c:
        ans[s-1] = c
    else:
        ans = [-1]
        break
else:
    for i in range(n):
        if ans[i] is None:
            ans[i] = 0 if i>0 else 1
        
print("".join(map(str,ans)))