spoj#TABLE5X5. Twofive
Twofive
English | Tiếng Việt |
Having a 5x5-table, we make a right-table by filling letters from 'A'..'Y' into the table satisfying:
- Each letter is used exactly one time.
- The letters is ascending on every row.
- The letters is ascending on every column.
Each right-table is described by a 25-length string, see the example below for detail:
The right-table:
A | B | C | D | E |
F | G | H | I | J |
K | L | M | N | O |
P | Q | R | S | T |
U | V | W | X | Y |
is described by the string "ABCDEFGHIJKLMNOPQRSTUVWXY".
All descriptions are sorted ascending (following the dictionary order) and numbered from 1.
Task
- Give an order, find the right description.
- Give a description, find the right order.
Input
- The first line contains a number (an order).
- The second line contains a description.
Output
- The first line contains the 25-length string desribing the order given.
- The second line contains the order of the given description.
Example
Input: 1 ABCDEFGHIJKLMNOPQRSTUVWXY Output: ABCDEFGHIJKLMNOPQRSTUVWXY 1