시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 417 141 108 39.706%

문제

성냥개비는 숫자를 나타내기에 아주 이상적인 도구이다. 보통 십진수를 성냥개비로 표현하는 방법은 다음과 같다.

성냥개비의 개수가 주어졌을 때, 성냥개비를 모두 사용해서 만들 수 있는 가장 작은 수와 큰 수를 찾는 프로그램을 작성하시오.

입력

첫째 줄에 테스트 케이스의 개수가 주어진다. 테스트 케이스는 최대 100개 이다. 각 테스트 케이스는 한 줄로 이루어져 있고, 성냥개비의 개수 n이 주어진다. (2 ≤ n ≤ 100)

출력

각 테스트 케이스에 대해서 입력으로 주어진 성냥개비를 모두 사용해서 만들 수 있는 가장 작은 수와 가장 큰 수를 출력한다. 두 숫자는 모두 양수이어야 하고, 숫자는 0으로 시작할 수 없다. 

예제 입력 1

4
3
6
7
15

예제 출력 1

7 7
6 111
8 711
108 7111111
W3sicHJvYmxlbV9pZCI6IjM2ODciLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWMxMzFcdWIwZTVcdWFjMWNcdWJlNDQiLCJkZXNjcmlwdGlvbiI6IjxwPlx1YzEzMVx1YjBlNVx1YWMxY1x1YmU0NFx1YjI5NCBcdWMyMmJcdWM3OTBcdWI5N2MgXHViMDk4XHVkMGMwXHViMGI0XHVhZTMwXHVjNWQwIFx1YzU0NFx1YzhmYyBcdWM3NzRcdWMwYzFcdWM4MDFcdWM3NzggXHViM2M0XHVhZDZjXHVjNzc0XHViMmU0LiBcdWJjZjRcdWQxYjUgXHVjMmVkXHVjOWM0XHVjMjE4XHViOTdjIFx1YzEzMVx1YjBlNVx1YWMxY1x1YmU0NFx1Yjg1YyBcdWQ0NWNcdWQ2MDRcdWQ1NThcdWIyOTQgXHViYzI5XHViYzk1XHVjNzQwIFx1YjJlNFx1Yzc0Y1x1YWNmYyBcdWFjMTlcdWIyZTQuPFwvcD5cclxuXHJcbjxwPjxpbWcgYWx0PVwiXCIgc3JjPVwiXC91cGxvYWRc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