# coding: utf-8


def main():
    n, m = map(int, input().split(' '))
    numbers_ = [0] * n
    for _ in range(m):
        s, c = map(int, input().split(' '))
        i = s - 1
        numbers_[i] = c

    if numbers_[0] == 0:
        print('-1')
        return 0

    sum_ = 0
    for i, number_ in enumerate(numbers_):
        sum_ += (number_ * 10 ** (len(numbers_) - i - 1))

    print(sum_)

    return 0


if __name__ == '__main__':
    main()
