def int_values(slr):
    l, r = map(lambda s: int(s), slr)
    return l, r


def comp_digits(digits):
    if digits[0] is None:
        digits[0] = '1'

    for i in range(1, len(digits)):
        if digits[i] is None:
            digits[i] = '0'


def main():
    N, M = int_values(input().split())
    digits = [None] * N
    valid = True

    for i in range(M):
        ss = input().split()
        s = int(ss[0])
        c = ss[1]
        if (s == 1 and c == 0) or (digits[s - 1] is not None):
            valid = False
        else:
            digits[s - 1] = c

    if valid:
        comp_digits(digits)
        print(''.join(digits))
    else:
        print('-1')


if __name__ == "__main__":
    main()
