'''
3 3
1 7
3 2
1 7  702

3 2
2 1
2 3  -1
'''
N,M = [int(x) for x in input().split()]
snc = [[int(x) for x in input().split()] for _ in range(M)]
answer = -1
for i in range(1000):
    curr = str(i)
    if len(curr) == N and all(curr[p - 1] == str(v) for p, v in snc):
        answer = i
print(answer)        
        


