Roundabout

Roundabout is a game show where two players compete against each other. There are 16 spheres arranged in four rows and four columns. Initially the spheres are all colored in white. As game progresses, these white spheres will be converted to one of the two colors of red and blue. Here red color is said to be the favorable color of first player and blue that of the second player. The game proceeds as follows: i. Each player is asked a question in turn. ii. If the first player answers a question correctly, he is able to turn one of the white spheres to red. Alternatively, the second player will be able to convert a white sphere to blue if he answers a question correctly. iii. If there is no white sphere left, a player can choose to convert any of the spheres colored in opposing players color. iv. If a player is not able to turn the color of any sphere because all the spheres are already turned into his favorable color, then the player is awarded a special score (see description below). The scoring of the game is as follows:

  1. Whenever a player converts a sphere into his favorable color, all the contiguous horizontal, vertical and diagonal matches with 3 or more favorable color containing the turned sphere will contribute to score for that turn according the following rule: a. All the matches containing 3 contiguous sphere of favorable color containing the turned sphere will contribute 3 points each. b. All the matches containing 4 contiguous sphere of favorable color containing the turned sphere will contribute 4 points each. c. A 4 contiguous match may also fulfill the requirement of one or more 3 contiguous match, in that case, all should be considered separately.
  2. If all the spheres are already turned into the favorable color of the player, then 50 points will be added to the score for that turn. When selecting a sphere to turn, the players use the following strategy:
  3. They will turn a sphere that will earn them maximum point involving that turn, as described earlier.
  4. If there is more than one such sphere, they will choose the sphere with lowest row value.
  5. If there is more than one sphere to choose in (ii), they will choose the sphere with the lowest column value. In this problem, you will be simulating different sessions of the game.

2/2 Input The first line of input contains a positive integer T (≤ 1000), denoting the number of test cases. This line will be followed by T lines, where each line describes one test case. It will consist of strings whose maximum length will be 50. These strings will consist of the characters ‘0’ and ‘1’ only. Here ‘1’ implies a correct response and ‘0’ implies an incorrect response. Starting with the first character, every character in the odd position corresponds to a response from the first player. Similarly, starting with the second character, every character in the even position corresponds to a response from the second player. Output For each case of input, there will be one line of input. It will first contain the case number followed by two integers. The first integer corresponds to the total score of the first player and the second integer corresponds to that of the second player. Look at sample output for exact formatting. Note: For the first case, only the first player gets the option to turn. In first two turns he converts first two spheres from the first row but gets no point. In 3rd turn he converts the 3rd ball from the first row and gets 3 point as it is a part of 3 contiguous horizontal spheres of his favorable color. In the 4th turn he converts the 4th ball in the first row and gets 7 points because the turned ball is a part of 4 contiguous horizontal spheres starting from 1, (4 points) and also a part of 3 contiguous horizontal spheres starting from 2 (3 points). Sample Input 4 10101010 011011001111 11111111 010111 Sample Output Case 1: 10 0 Case 2: 0 3 Case 3: 3 3 Case 4: 0 0