eolymp
bolt
Try our new interface for solving problems

Zero

Let’s consider the sequence of digits from \textbf{1} through \textbf{N} (where \textbf{N} = \textbf{9}) in increasing order: \textbf{1 2 3 ... N}. Now insert either a "\textbf{+}" for addition or a "\textbf{-}" for subtraction or a " " \[blank\] to run the digits together, between each pair of digits (not in front of the first digit). Calculate the result that of the expression and see if you get zero. Write a program that will find all sequences of length \textbf{N} that produce a zero sum. \InputFile The first line of the input contains the number of test cases \textbf{T} (\textbf{T} < \textbf{10}). Single test case is represented by single line that contains the integer \textbf{N} (\textbf{3} ≤ \textbf{N} ≤ \textbf{9}). \OutputFile For each test case in \textbf{ASCII} order, print each sequence that can create \textbf{0} sum with a '\textbf{+}', '\textbf{-}', or ' ' (space) between each pair of numbers. Space shows that the digits run together. Different test cases should be separated by an empty line.
Time limit 1 second
Memory limit 64 MiB
Input example #1
1
3
Output example #1
1+2-3
Source All-Ukrainian Collegiate Programming Contest Semi-Final 2010