Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register
Language:
Little guys' game
 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 606 Accepted: 182

Description

Here is game played by little guys. There is a 4 * 4 square, and the square is filled with the characters 'A', 'B', 'C' and 'D'. Each kind of character appears exactly 4 times. You can arbitrarily swap two adjacent characters (horizontal or vertical). At the beginning of the game you should choose a character (from 'A', 'B', 'C' and 'D') as you target character, when any 2 * 2 sub-square contains the same character as the character you have chosen before, you win the game.

These little guys want to use minimal times of swap to win the game. Now they turn to you. Can you help them?

Input

There are multiple test cases. Each contains a 4 * 4 square as the initial situation. Notice that the square only contains 'A', 'B', 'C' and 'D', and each kind of characters will appear exactly 4 times.

Output

You should output the minimal swap times to win the game, and you should also output how many kinds of strategies you can achieve the minimal swap times.

You should pay attention that if two strategies swap the characters in the same order but with the different target characters, these two strategies are still considered as different.

Sample Input

```AABB
ABAB
CDCD
CCDD

ACAB
CBBD
DCBC
```

Sample Output

```1 4
4 96```

Source

[Submit]   [Go Back]   [Status]   [Discuss]