#K33622. Taco Score Calculator

    ID: 25129 Type: Default 1000ms 256MiB

Taco Score Calculator

Taco Score Calculator

You are given a list of participants and their scores for a series of problems. For each participant, the first number indicates the number of problems attempted. For each subsequent problem, two integers are provided: the score obtained and the penalty incurred.

The final score for each participant is calculated by summing the differences between the score and the penalty for each problem. Formally, if a participant solved N problems and for the i-th problem the score is a_i and the penalty is b_i, then the final score is

[ \text{final score} = \sum_{i=1}^{N} (a_i - b_i) ]

Your task is to compute and output the final score for every participant.

inputFormat

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

  1. An integer P representing the number of participants.
  2. For each participant:
    • An integer N representing the number of problems solved.
    • 2 * N integers representing pairs of a (score) and b (penalty) for each problem.

All integers are space-separated and may span multiple lines.

outputFormat

Output to standard output (stdout) a single line with P integers separated by a space representing the final scores for each participant in the order they appear in the input.

## sample
2
3 10 4 15 2 20 0 2 8 1 20 5
39 22