TABLE5X5 - Twofive

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

Được gửi lên bởi:AnhDQ
Ngày:2009-05-14
Thời gian chạy:0.100s
Giới hạn mã nguồn:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Ngôn ngữ cho phép:Tất cả ngoại trừ: ERL GOSU JS-RHINO NODEJS PERL6 PYPY RUST SED VB.NET
Nguồn bài:IOI2001

hide comments
2009-05-16 03:51:36 dhkhtn
1s cung duyet duoc sao?
2009-05-15 21:54:58 AnhDQ
Time limit update rồi, đề nghị quên các ý tưởng duyệt :">
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.