SP13364 WITTY - THE N WITTY FRIENDS
Description
**Problem Statement:**
N witty friends went for an outing trip. During the outing they have spent lot of money in lot of places. In some places, a friend (A) spends ‘M’ money for his friend (B).
An expense is described by "A spends M$ for B"
A transaction is described by “X gives K$ to Y”
You are given all the expenses made by the friends. The outing trip is ended and now you have to find the minimum transactions to be made by the friends to tally the expenses.
**Input:**
The first line consists of an integer t, the number of testcases. For each test case, the first line consists of an integer N, the number of expenses made by friends followed by N lines. Each line contains two strings A and B (A!=B) and an integer m, the money A spent for B.
**Output:**
For each test case, print the minimum number of transactions required to tally the expenses.
**Input Constraints:**
1
Input Format
N/A
Output Format
N/A