N, M = map(int, input().split(' '))

A = [10 for _ in range(N)]

for _ in range(M):
    s, c = map(int, input().split(' '))
    if A[s-1] > c:
        A[s-1] = c

if A[0] == 10 or A[0] == 0:
    print('-1')
else:
    for i in range(N):
        if A[i] == 10:
            A[i] = 0
    print(''.join(map(str, A)))