#P7383. 「EZEC-6」加减

「EZEC-6」加减

Description

You are given two numbers n,mn, m. You need to split mm into nn distinct positive integers (that is, the sum of these nn numbers is mm), such that within the interval [1,m][1, m], there is at least one positive integer that cannot be obtained by adding and subtracting these nn numbers (each number can be used at most once in the adding/subtracting process).

That is, let the ii-th number among the nn positive integers be aia_i. You need to ensure that within [1,m][1, m], there exists at least one positive integer that cannot be represented in the form $\sum\limits^{n}_{i=1} k_i \times a_i \ (k_i \in \{-1, 0, 1\})$.

If there is no solution, output -1.

If there is a solution, output any set of nn positive integers that meets the requirement, and also output any number in [1,m][1, m] that cannot be represented.

Input Format

This problem has multiple test cases.

The first line contains a positive integer TT, the number of test cases.

For each test case, one line contains two positive integers n,mn, m.

Output Format

For each test case:

If there is no solution, output one line -1.

If there is a solution, output nn positive integers in the first line, representing a valid solution, and output one positive integer in [1,m][1, m] in the second line. This integer cannot be represented.

4
2 6
3 18
1 1
2 4
1 5
3
5 6 7
3
-1
-1

Hint

This problem uses bundled tests.

  • Subtask 1 (10 points): n2n \le 2.
  • Subtask 2 (20 points): 2n2m2n^2 \le m.
  • Subtask 3 (20 points): 1.5n2m\lceil 1.5n^2 \rceil \le m.
  • Subtask 4 (20 points): n5n \le 5.
  • Subtask 5 (30 points): no special constraints.

Constraints: For 100%100\% of the testdata, 1T1001 \le T \le 100, 1n,m1041 \le n, m \le 10^4.

Translated by ChatGPT 5