digit, constraints_count = [int(num) for num in input().split(' ')]

constraints = [-1, -1, -1]

for i in range(constraints_count):
    const_digit, const_num = [int(num) for num in input().split(' ')]
    if const_digit <= digit and constraints[const_digit - 1] != -1 and constraints[const_digit - 1] != const_num:
        print(-1)
        exit()
    if const_digit == 1 and const_num == 0:
        print(-1)
        exit()

    constraints[const_digit - 1] = const_num


if constraints[0] == -1:
    if digit != 1:
        constraints[0] = 1
    else:
        constraints[0] = 0

for i in range(3):
    if constraints[i] == -1:
        constraints[i] = 0

num_str = ""
for i in range(digit):
    num_str += str(constraints[i])

print(num_str)