def main():
    digits, orders = [int(x) for x in input().split()]
    number = [-1] * digits
    for _ in range(orders):
        left_count, numeral = [int(x) for x in input().split()]
        left_count -= 1
        if number[left_count] != -1:
            # already assigned!
            if number[left_count] != numeral:
                print(-1)
                return
        else:
            number[left_count] = numeral
    if number[0] == 0:
        print(-1)
        return
    if number[0] == -1:
        number[0] = 1
    for x in number:
        if x == -1:
            x = 0
        print(x, end='')
    return


if __name__ == '__main__':
    main()
