n,m=map(int, input().split())
r = []

for i in range(m):
    r.append(str(0))

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

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

