dic = {}
n, m  = map(int, input().split())
result = ['0'] * n

for i in range(m):
    s, c = input().split()
    result[int(s)-1] = c
    
sentence = ''.join(result)
if sentence[0] == '0':
    print(-1)
else:
    print(sentence)
    