Period of a String
시간 제한1초메모리 제한2048 MB
각 문자열의 문자를 교환해 이전 문자열이 다음 문자열의 주기가 되도록 만들 수 있는지 판별하고, 가능하면 결과 문자열을 출력한다.
문제
Randias has strings .
For two strings and , if for all (), , we say that is a period of .
Now, Randias can perform the following operation:
- Choose one string and choose two indices and (), then swap and .
He can perform this operation any number of times. After all the operations, he wants the following to be true: for each , string is a period of .
Help him to find the possible final strings, or determine it is impossible.
입력
Each test contains multiple test cases. The first line contains a single integer () denoting the number of test cases. For each test case:
The first line contains a single integer ().
Then follow lines. The -th of these lines contains the string (). It is guaranteed that the strings only contain lowercase English letters.
It is guaranteed that the sum of does not exceed , and the sum of does not exceed .
출력
For each test case, if it is possible to make a period of for all after some operations, output "YES" (without quotes) on the first line. Then output strings in lines. The -th string represents the -th string after all operations. If there are multiple answers, output any one of them.
If it is impossible to do that, output "NO" (without quotes) on the first line.