시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 504 374 350 74.468%

문제

1보다 크거나 같고 12보다 작거나 같은 자연수가 주어졌을 때, 합이 n이 되는 두 수의 쌍을 찾는 프로그램을 작성하시오.

예를 들어, 5가 주어진 경우 가능한 쌍은 1,4와 2,3이 있다. 두 수는 항상 달라야 한다. 즉, 3,3은 올바른 쌍이 아니다. 또, 첫 번째 숫자가 두 번째 숫자보다 작아야 한다.

출력하는 쌍은 항상 사전순으로 출력해야 한다. 즉, 각 쌍의 작은 숫자로 비교를 해야 한다. 예를 들어 1,5는 2,4보다 사전순으로 앞선다.

입력

첫째 줄에 테스트 케이스의 수 (< 100)가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있고, n이 주어진다.

출력

각 테스트 케이스마다 n을 만드는 쌍을 사전순으로 출력한다. n을 만드는 쌍이 없는 경우에는 아무것도 출력하지 않는다.

예제 출력 형식을 참고해 출력한다.

예제 입력 1

4
2
3
4
5

예제 출력 1

Pairs for 2:
Pairs for 3: 1 2
Pairs for 4: 1 3
Pairs for 5: 1 4, 2 3
W3sicHJvYmxlbV9pZCI6IjUyMTciLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWMzMGRcdWM3NTggXHVkNTY5IiwiZGVzY3JpcHRpb24iOiI8cD4xXHViY2Y0XHViMmU0IFx1ZDA2Y1x1YWM3MFx1YjA5OCBcdWFjMTlcdWFjZTAgMTJcdWJjZjRcdWIyZTQgXHVjNzkxXHVhYzcwXHViMDk4IFx1YWMxOVx1Yzc0MCBcdWM3OTBcdWM1ZjBcdWMyMThcdWFjMDAgXHVjOGZjXHVjNWI0XHVjODRjXHVjNzQ0IFx1YjU0YywgXHVkNTY5XHVjNzc0IG5cdWM3NzQgXHViNDE4XHViMjk0IFx1YjQ1MCBcdWMyMThcdWM3NTggXHVjMzBkXHVjNzQ0IFx1Y2MzZVx1YjI5NCBcdWQ1MDRcdWI4NWNcdWFkZjhcdWI3YThcdWM3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