eolymp
bolt
Try our new interface for solving problems
Problems

Science!

Science!

Welcome, ladies and gentlemen, to Aperture Science. Astronauts, War Heroes, Olympians --- you’re here because we want the best, and you are it. That said, it’s time to make some science. Now, I want each of you to stand on one of these buttons. Well done, we’re making great progress here. Now let’s do it again. Oh, come on - don’t stand on the same button! Move, people! No, no, that button’s only for the Astronauts, you know who you are. What?! You say you can’t do everything I ask? Ok let’s start over. You there, the Programmer, figure out how many times we can do this. And make it quick, we have a lot more science to get through… \InputFile There will be several test cases in the input. The first line of each case will contain \textbf{n} (\textbf{2} ≤ \textbf{n} ≤ \textbf{80}) giving the number of people (and the number of buttons) in the experiment. The next \textbf{n} lines will contain \textbf{n} characters each. If the \textbf{j}^thcharacter of the ith line is \textbf{Y} it indicates that the \textbf{i}^th person can stand on the \textbf{j}^th button (it is \textbf{N} otherwise). The last line of input will be a \textbf{0}. \OutputFile For each test case, output \textbf{k}, the maximum number of times everyone can be standing on buttons such that nobody stands on the same button more than once (This might be \textbf{0}). After that, output \textbf{k} lines. Each line should contain \textbf{n}integers separated by single spaces, where the ith integer describes which person is standing on the ith button. All of the lines should be valid and none of them should put the same person on the same button as a previous line of the same test case. Output no extra spaces, and do not separate answers with blank lines. Note that correct outputs might not be unique.
Time limit 2 seconds
Memory limit 32 MiB
Input example #1
3
YYY
NYY
YNY
2
YN
YN
0
Output example #1
2
3 1 2
1 2 3
0
Source The University of Chicago Invitational Programming Contest 2012 15 April 2012