#C9957. Determine Game Winners

    ID: 54107 Type: Default 1000ms 256MiB

Determine Game Winners

Determine Game Winners

You are given several games, each with a number of rounds. In each round, two players compete and obtain a score. The player with the higher score in a round wins that round; if both scores are equal, the round is a draw. For each game, your task is to determine the overall winner based on the number of rounds won.

The rules for determining the winner for a single game are as follows:

  • If player 1 wins more rounds than player 2, output 1.
  • If player 2 wins more rounds than player 1, output 2.
  • If both players win the same number of rounds, output 0.

The problem input is provided via standard input and the result for each game should be printed to standard output.

Note: Use LaTeX format for any mathematical expressions. For example, if you refer to the number of rounds as \(N\) or the number of games as \(T\), use the proper LaTeX formatting.

inputFormat

The input is read from standard input (stdin) and has the following format:

T
N1
a11 b11
... 
a1N1 b1N1
N2
... 
...
NT
...

Here, \(T\) is the number of games. Then for each game, an integer \(N\) (\(N \ge 1\)) is provided which denotes the number of rounds in this game, followed by \(N\) lines, each containing two integers \(a\) and \(b\) representing the scores of player 1 and player 2 in that round respectively.

outputFormat

Print \(T\) lines to standard output (stdout). Each line should contain a single integer that is the winner of the corresponding game: 1 if player 1 wins more rounds, 2 if player 2 wins more rounds, and 0 if the number of wins are equal.

## sample
1
1
3 3
0

</p>