TABLE5X5 - Twofive

no tags 

Having a 5×5-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:

ABCDE
FGHIJ
KLMNO
PQRST
UVWXY

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

hide comments
smso: 2020-03-06 18:53:23

more testcases:
2
ABCDE
FGHIJ
KLMNO
PQRSU
TVWXY


3
ABCDE
FGHIJ
KLMNO
PQRSV
TUWXY


4
ABCDE
FGHIJ
KLMNO
PQRSW
TUVXY


5
ABCDE
FGHIJ
KLMNO
PQRSX
TUVWY

[Trichromatic] XilinX: 2009-05-16 01:03:37

You may set several test case in one test file and set the time limit to 1 second rather than 0.05 second per test.
P.S Don't set time limit lower than 0.5 second please.

AnhDQ: 2009-05-15 21:51:01

Time limit has been updated to be like the root problem ;) someone missed AC :d


Added by:AnhDQ
Date:2009-05-14
Time limit:0.100s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:IOI2001