# -*- coding: utf-8 -*-


def main():
    n, m = map(int, input().split())
    joken_list = [tuple(map(int, input().split())) for i in range(m)]

    init_num = 0
    limit_num = 10 ** n

    result = "-1"
    for i in range(init_num, limit_num):
        i_s = str(i)
        match = True
        for keta, value in joken_list:
            if i_s[keta - 1 : keta] != str(value):
                match = False
                break

        if match:
            result = i_s
            break

    print(result)

if __name__ == '__main__':
    main()
