시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 399 175 151 49.671%

문제

1부터 N까지의 수를 오름차순으로 쓴 수열 1 2 3 ... N을 생각하자.

그리고 '+'나 '-', 또는 ' '(공백)을 숫자 사이에 삽입하자(+는 더하기, -는 빼기, 공백은 숫자를 이어 붙이는 것을 뜻한다). 이렇게 만든 수식의 값을 계산하고 그 결과가 0이 될 수 있는지를 살피자.

N이 주어졌을 때 수식의 결과가 0이 되는 모든 수식을 찾는 프로그램을 작성하라.

입력

첫 번째 줄에 테스트 케이스의 개수가 주어진다(<10).

각 테스트 케이스엔 자연수 N이 주어진다(3 <= N <= 9).

출력

각 테스트 케이스에 대해 ASCII 순서에 따라 결과가 0이 되는 모든 수식을 출력한다. 각 테스트 케이스의 결과는 한 줄을 띄워 구분한다.

예제 입력 1

2
3
7

예제 출력 1

1+2-3

1+2-3+4-5-6+7
1+2-3-4+5+6-7
1-2 3+4+5+6+7
1-2 3-4 5+6 7
1-2+3+4-5+6-7
1-2-3-4-5+6+7
W3sicHJvYmxlbV9pZCI6Ijc0OTAiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiIwIFx1YjljY1x1YjRlNFx1YWUzMCIsImRlc2NyaXB0aW9uIjoiPHA+MVx1YmQ4MFx1ZDEzMCBOXHVhZTRjXHVjOWMwXHVjNzU4IFx1YzIxOFx1Yjk3YyBcdWM2MjRcdWI5ODRcdWNjMjhcdWMyMWNcdWM3M2NcdWI4NWMgXHVjNGY0IFx1YzIxOFx1YzVmNCAxIDIgMyAuLi4gTlx1Yzc0NCBcdWMwZGRcdWFjMDFcdWQ1NThcdWM3OTAuPFwvcD5cclxuXHJcbjxwPlx1YWRmOFx1YjlhY1x1YWNlMCAmIzM5OysmIzM5O1x1YjA5OCAmIzM5Oy0mIzM5OywgXHViNjEwXHViMjk0ICYjMzk7ICYjMzk7KFx1YWNmNVx1YmMzMSlcdWM3NDQgXHVjMjJiXHVjNzkwIFx1YzBhY1x1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