This page is still under construction.

Parts of this page are still being built. What you see may change.

Undercut

Time limit1sMemory limit128 MB

Summary
Add up both players' scores across card rounds where the higher card scores unless the lower card is exactly one less.
Level

Easy2 of 10

Topics
Simulation, Implementation
Solved
No attempts yet

Problem

Undercut is a game for two players, each holding five cards numbered 11 through 55. In every round both players secretly choose one of their cards and then reveal them at the same time. Scoring works like this. The player with the higher card scores the value of that card, unless the other card is exactly one less. In that case the player with the lower card scores the sum of the two cards, which is called an undercut. If both players reveal the same card, nobody scores. For example, if Tessa plays a 55 and Danny plays a 33, Tessa scores 55 points, but if Tessa plays a 55 and Danny plays a 44 instead, Danny scores 5+4=95+4=9 points.

Undercut is a fine mental game, because each side keeps second-guessing: they think I will play a 55, so they will play a 44, so I will play a 33 and undercut them, but they will expect that and play a 22, so I will just play a 55, and then they will think... This problem does not model that reasoning. You are given the cards both players actually revealed and you have to work out the final score. One rule changes: undercutting a 22 with a 11 scores 66 points instead of 33, which in the real game makes the 11 worth playing.

Input

The first line contains an integer nn, the number of test cases.

Each test case starts with a line containing a positive integer mm with m≤100m \le 100, the number of rounds in that game. After it come 2m2m integers on one or more lines. Taking them two at a time gives the cards played in each round: the first two numbers are the cards Tessa and Danny played in the first round, the next two are their cards in the second round, and so on. Every card value is between 11 and 55, inclusive.

Output

For each test case, print Tessa's and Danny's final scores on one line in this format.

Game k: Tessa a Danny b

Here kk is the test case number starting from 11, aa is Tessa's score, and bb is Danny's score.

Examples1

  1. Example 1

    Input
    2
    3
    5 3 5 4 2 5
    10
    3 5 1 2 3 2 1 2 1 5 3 2
    1 3 4 2 3 3 1 3
    
    Expected output
    Game 1: Tessa 5 Danny 14
    Game 2: Tessa 16 Danny 26