if __name__ == '__main__':
    n, m = tuple([int(s) for s in input().split()])
    digits = [None] * 3
    failed = False

    for i in range(m):
        si, ci = tuple([int(s) for s in input().split()])

        if si > n:
            print(-1)
            failed = True
            break
        elif digits[n - si] is not None and digits[n - si] != ci:
            print(-1)
            failed = True
            break
        else:
            digits[n - si] = ci

    if not failed:
        if digits[-1] == 0:
            print(-1)
        else:
            digits = digits[:n]
            digits.reverse()
            if digits[0] is None:
                digits[0] = 1
            for j in range(len(digits)):
                if digits[j] is None:
                    digits[j] = 0

            print("".join(["{}".format(d) for d in digits]))
