Continuous Same Game (2)

Time Limit: 3000ms
Memory Limit: 32768KB
This problem will be judged on HDU. Original ID: 2259
64-bit integer IO format: %I64d      Java class name: Main
Special Judge

Description

After repeated attempts, LL finds the greedy strategy is very awful in practice. Even there is no apparent evidence to proof it is better than a random one. So he has to drop this strategy and try to discover a better one.

Input

There are 100 test cases. Each test case begins with two integers n,m ( 5<=n,m<=20 ), which is the size of the board. Then n lines follow, each contains m characters, indicating the color of the block. There are 5 colors, and each with equal probability.

Output

For each test case, first output a single line containing the number of steps S. Then S lines follow, each contains two integers indicating the position of an arbitrary block of the group you want to remove.

For the i-th test case, let Ai is the total point of your scheme and Bi is the total point of the greedy strategy . Then I will calculate the average of (Ai/Bi), 1<=i<=100. You will get WA if your ouput is invalid or this average is less than 1.5.

Sample Input

5 5
35552
31154
33222
21134
12314

Sample Output

5
2 2
0 0
1 1
2 1
4 4
Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .