n,m = map(int,input().split())
s = []
c = []
ans = [1]
for i in range(n-1):
    ans.append("0")

for i in range(m):
    S,C = map(int,input().split())
    s.append(S)
    c.append(C)
    
for i in range(m):
    ans[s[i]-1] = c[i]
    
    if i == m-1:
        ANS = ""
        for j in range(n):
            ANS += str(ans[j])
            
for i in range(m):
    if s[i] == 1 and c[i]==0:
        ANS = -1
    
    for j in range(m):
        if s[i] == s[j] and c[i] != c[j]:
            ANS = -1
            
print(ANS)