n,m=map(int, input().split())
box = ["0" for _ in range(n)]
for i in range(m):
    s,c = map(int, input().split())
    box[s-1] = str(c)
#print(box)
ans=''  
if box[0] == '0':
    print(-1)
    
else:
    for x in box:
        ans += x
    print(int(ans))
    
    
    
