# coding: utf-8
# Your code here!

N,M = [int(i) for i in input().split()]


numbers = ['0'] * N

for _ in range(M):
    s,c = input().split()
    s = int(s)
    numbers[s-1] = c

if len(numbers) > 1 and numbers[0] == '0':
    print('-1')
else:
    print(''.join(numbers))
