#ABC473D. 系数阶梯 / Coefficient Stair

系数阶梯 / Coefficient Stair

Problem Statement

Output all length-NN sequences A=(A1,A2,,AN)A=(A_1,A_2,\ldots,A_N) consisting of non-negative integers that satisfy i=1Ni×Ai=K\displaystyle\sum_{i=1}^{N} i\times A_i=K, in lexicographic order from smallest to largest.

Here, you will only receive inputs such that the number of sequences satisfying the condition is at most 3×1053\times10 ^ 5.

What is lexicographic order for sequences?

A sequence S=(S1,S2,,SS)S = (S_1,S_2,\ldots,S_{|S|}) is said to be lexicographically smaller than a sequence T=(T1,T2,,TT)T = (T_1,T_2,\ldots,T_{|T|}) if either 1. or 2. below holds. Here, S|S| and T|T| denote the lengths of SS and TT, respectively.

  1. S<T|S| \lt |T| and $(S_1,S_2,\ldots,S_{|S|}) = (T_1,T_2,\ldots,T_{|S|})$.
  2. There exists an integer 1imin{S,T}1 \leq i \leq \min\lbrace |S|, |T| \rbrace such that both of the following hold.
    • $(S_1,S_2,\ldots,S_{i-1}) = (T_1,T_2,\ldots,T_{i-1})$
    • SiS_i is (numerically) smaller than TiT_i.

Constraints

  • 1N101\le N\le 10
  • 1K2×1051\le K\le 2\times10 ^ 5
  • The number of sequences satisfying the condition is at most 3×1053\times10 ^ 5.
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

  • NN KK

Output

Let qq be the number of sequences of non-negative integers satisfying the condition; output them over qq lines. Each line should contain the elements of a sequence of non-negative integers satisfying the condition, in order, separated by spaces. For every sequence, all sequences outputed before it must be lexicographically smaller than it.

3 8
0 1 2
0 4 0
1 2 1
2 0 2
2 3 0
3 1 1
4 2 0
5 0 1
6 1 0
8 0 0

For example, for the sequence (0,1,2)(0,1,2) we have 0×1+1×2+2×3=0+2+6=80\times1+1\times2+2\times3=0+2+6=8, so it satisfies the condition. There is no sequence satisfying the condition that is lexicographically smaller than this one, so output 0 1 2 on the first line.

Including (0,1,2)(0,1,2), ten sequences satisfy the condition. Output these in lexicographic order from smallest to largest.

1 200000
200000
8 9
0 0 0 1 1 0 0 0
0 0 1 0 0 1 0 0
0 0 3 0 0 0 0 0
0 1 0 0 0 0 1 0
0 1 1 1 0 0 0 0
0 2 0 0 1 0 0 0
0 3 1 0 0 0 0 0
1 0 0 0 0 0 0 1
1 0 0 2 0 0 0 0
1 0 1 0 1 0 0 0
1 1 0 0 0 1 0 0
1 1 2 0 0 0 0 0
1 2 0 1 0 0 0 0
1 4 0 0 0 0 0 0
2 0 0 0 0 0 1 0
2 0 1 1 0 0 0 0
2 1 0 0 1 0 0 0
2 2 1 0 0 0 0 0
3 0 0 0 0 1 0 0
3 0 2 0 0 0 0 0
3 1 0 1 0 0 0 0
3 3 0 0 0 0 0 0
4 0 0 0 1 0 0 0
4 1 1 0 0 0 0 0
5 0 0 1 0 0 0 0
5 2 0 0 0 0 0 0
6 0 1 0 0 0 0 0
7 1 0 0 0 0 0 0
9 0 0 0 0 0 0 0