def main():
    N, M = [int(x) for x in input().split()]
    expected_num_ary = [1] + [-1] * (N - 1)

    if N == 1 and M == 0:
        print("0")
        return

    inputted_digit = []
    for _ in range(M):
        d, v = [int(x) for x in input().split()]
        if d in inputted_digit and expected_num_ary[d - 1] != v:
            print("-1")
            return
        if d == 1 and v == 0:
            # 明示的に桁数をズラシに来ているケース
            print("-1")
            return
        expected_num_ary[d - 1] = v
        inputted_digit.append(d)

    num_str = ""
    for num in expected_num_ary:
        num_str += str(num) if num != -1 else "X"

    tester = num_str.lstrip("0").replace("X", "0")

    if N > len(tester):
        print("1%0*d" % (N - 1, int(tester)))
    else:
        print(tester)



if __name__ == '__main__':
    main()
