n,m = map(int,input().split())
ns = list('0'*n)

s = [0]*m
c = [0]*m

for i in range(m):
    s, c = map(int, input().split())
    ns[s-1] = str(c)

if ns[0] == '0':
    ans = -1
else:
    ans = ''.join(ns)
print(ans)