import numpy as np

N, M = map(int, input().split(' '))
input_line = [list(map(int, input().split(' '))) for _ in range(M)]

input_line = list(map(list, set(map(tuple, input_line))))
result = True
conditions = [[] for _ in range(2)]
for x in input_line:
    if x[0] > N or x[0] in conditions[0] or (x[0] == 1 and x[1] == 0):
        result = False
        break
    elif x[0] not in conditions[0]:
        conditions[0].append(x[0])
        conditions[1].append(x[1])

answer = ''
if result:
    for i in range(1, N+1):
        if i in conditions[0]:
            answer +=  str(conditions[1][conditions[0].index(i)])
        elif i == 1:
            answer += '1'
        else:
            answer += '0'
    print(int(answer))
else:
    print('-1')
