Page not loading? Try clicking here.
Placeholder

#1175

Roll a Die 2 1s 32MB

Problems

Write a program that, given natural numbers N and M, prints all possible cases where rolling a die N times results in a total sum of M.


Input

The first line contains two integers:

  • N: the number of die rolls (2 ≤ N ≤ 8)

  • M: the target sum of the dice (1 ≤ M ≤ 40)


Output

Print all cases in which the sum of the N die rolls equals M.

The results should be printed starting from the smallest numbers.


Example

3 10
1 3 6

1 4 5
1 5 4
1 6 3
2 2 6
2 3 5

6 2 2
6 3 1


Source

JUNGOL

You must sign in to write code.