Print All Subsequences with Sum K
Generate all subsequences of an array whose elements sum to a given K.
Input format
The first line contains N (N ≤ 12) and K. The second line contains N integers.
Output format
Print every subsequence whose elements sum to K, one per line as space-separated values in their original order. Sort the lines lexicographically as strings. If none exists, print -1.
Constraints
- Values fit in a 64-bit signed integer
- Trailing whitespace and a trailing newline are ignored by the judge
Read from stdin, write to stdout. Sample cases below show the exact format.
Sample cases
Example 1
Input
3 3
1 2 3Expected output
1 2
3Example 2
Input
4 100
1 2 3 4Expected output
-1