## Algorithm

Problem Name: 2 AD-HOC - beecrowd | 2247

# Grandma Vitória's Piggy Banks

By OBI - Olimpíada Brasileira de Informática 2003 Brazil

Timelimit: 1

Grandma Victoria maintains since the birth of the grandsons Hansel and Zezinho , a ritual that is the delight of boys. She keeps all the coins received as change in two small piggy banks, one for each grandson. When one of piggy banks becomes full, she calls the two grandsons for a lively lunch at the end of which the delivery boys saved the coins in each piggy banks.

She was always very zealous about the equal distribution of the collected change. Where by reason of the value of coins, she can not put the same amount in the two piggy banks, she memorizes the difference in order to make up for it next deposit.

Grandma Victoria is getting old and is afraid that memory lapses to do commit injustices with her grandsons, failing to compensate for differences between the piggy banks. Your task is to help Grandma Victoria, writing a computer program that displays the differences between the deposits, so that it does not have to worry about memorizing them.

## Input

The input consists of several test sets. The first line of a test set contains an integer N (0 ≤ N ≤ 100), indicating the number of deposits in piggy banks. The N following lines describe each of a deposit in piggy banks; the deposit is indicated by two integer values J e Z (0 ≤ J,Z ≤ 100), separated by a blank space, representing respectively the values in cents, deposited in the vaults of the grandsons Hansel and Zezinho. The end of input is indicated by N = 0.

## Output

For each input set of test his program to produce a set of rows in the output. The first line should contain a test set identifier in the format "Teste n", where n is sequentially numbered from 1. Then your program must write one line for each tank set of tests. Each line should contain an integer representing the difference (in cents) between the amount deposited in piggy banks of Hansel and Zezinho. Let a blank line at the end of each test set. The spelling shown in Example output below should be followed strictly.

 Input Sample Output Sample 3 20 25 10 5 10 10 4 0 5 12 0 0 20 17 1 0 Teste 1 -5 0 0 Teste 2 -5 7 -13 3

## Code Examples

### #1 Code Example with C Programming

```Code - C Programming```

``````
#include <stdio.h>

#define true 1
#define false 0
#define MAXSIZE 110

int main (void)
{

short saldo, i, teste;
unsigned short n, a, b;

teste = 0;
while (scanf("%hu", &n), n)
{

saldo = 0;
printf("Teste %hd\n", ++teste);
for (i = 0; i  <  n; ++i)
{

scanf("%hd %hd", &a, &b);
saldo += a;
saldo -= b;
printf("%hd\n", saldo);

}

printf("\n");
}

}
``````
Copy The Code &

Input

cmd
3
20 25
10 5
10 10
4
0 5
12 0
0 20
17 1
0

Output

cmd
Teste 1
-5
0
0

Teste 2
-5
7
-13
3

### #2 Code Example with C++ Programming

```Code - C++ Programming```

``````
#include <cstdio>
int main() {
int n, teste = 1;
while (scanf("%d", &n) && n) {
printf("Teste %d\n", teste++);
int saldo = 0;
while (n--) {
int x, y;
scanf("%d %d", &x, &y);
saldo += x - y;
printf("%d\n", saldo);
}
printf("\n");
}
return 0;
}
``````
Copy The Code &

Input

cmd
3
20 25
10 5
10 10
4
0 5
12 0
0 20
17 1
0

Output

cmd
Teste 1
-5
0
0

Teste 2
-5
7
-13
3