n,m = map(int,input().split())
ns = list('1' + '0'*(n-1))
ss, cc = -1, -1
for i in range(m):
    s, c = map(int, input().split())
    if s == ss and c != cc:
        ns[0] = '0'
        break
    ns[s-1] = str(c)
    ss, cc = s, c
    
if len(ns) > 1 and ns[0] == '0':
    ans = -1
else:
    ans = ''.join(ns)
print(ans)