AT_abc473_d [ABC473D] Coefficient Stair

Description

Output all length- $ N $ sequences $ A=(A _ 1,A _ 2,\ldots,A _ N) $ consisting of non-negative integers that satisfy $ \displaystyle\sum _ {i=1} ^ Ni\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\times10 ^ 5 $ . What is lexicographic order for sequences?A sequence $ S = (S_1,S_2,\ldots,S_{|S|}) $ is said to be **lexicographically smaller** than a sequence $ T = (T_1,T_2,\ldots,T_{|T|}) $ if either 1. or 2. below holds. Here, $ |S| $ and $ |T| $ denote the lengths of $ S $ and $ T $ , respectively. 1. $ |S| \lt |T| $ and $ (S_1,S_2,\ldots,S_{|S|}) = (T_1,T_2,\ldots,T_{|S|}) $ . 2. There exists an integer $ 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}) $ - $ S_i $ is (numerically) smaller than $ T_i $ .

Input Format

The input is given from Standard Input in the following format: > $ N $ $ K $

Output Format

Let $ q $ be the number of sequences of non-negative integers satisfying the condition; output them over $ q $ 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.

Explanation/Hint

### Sample Explanation 1 For example, for the sequence $ (0,1,2) $ we have $ 0\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) $ , ten sequences satisfy the condition. Output these in lexicographic order from smallest to largest. ### Constraints - $ 1\le N\le 10 $ - $ 1\le K\le 2\times10 ^ 5 $ - The number of sequences satisfying the condition is at most $ 3\times10 ^ 5 $ . - All input values are integers.