n, m = map(int, input().split())
numbers = [0]*n
existence = False

for _ in range(m):
    s, c = map(int, input().split())
    if c > numbers[s-1]:
        numbers[s-1] = c
    if s == 1:
        if not c == 0:
            existence = True

if existence:
    print(*numbers, sep='')
else:
    print(-1)
