n, m = map(int, input().split())
tmp = ['a'] * n
for _ in range(m):
    s, c = input().split()
    tmp[int(s)-1] = c

num = ''.join(tmp).replace('a', '0')
num = int(num)

if len(str(num)) == n:
    print(num)
else:
    print('-1')
