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
2 4 4
2 5 3
2 6 2
3 1 6
3 2 5
3 3 4
3 4 3
3 5 2
3 6 1
4 1 5
4 2 4
4 3 3
4 4 2
4 5 1
5 1 4
5 2 3
5 3 2
5 4 1
6 1 3
6 2 2
6 3 1
Tag
Source
JUNGOL