Redcrown the Bear is a gamer who likes playing hardcore games such as I Wanna series. As an experienced player, he has also made many I Wanna levels by himself.
Redcrown is making a new level with a puzzle: given $$$\tilde{k},\tilde{x}$$$ and several consecutive positive integers from $$$l$$$ to $$$r$$$, the player needs to determine whether there exist $$$\tilde{k}$$$ different integers such that their sum is $$$\tilde{x}$$$. Now Redcrown needs to decide the range of the given integers in this level, denoted by the interval $$$[l,r]$$$. In addition to $$$0 \lt l \le r$$$, he wants to make the interval satisfy $$$n$$$ conditions, each of which is of one of the following two types:
Redcrown wants to know the number of different intervals $$$[l,r]$$$ that satisfy the conditions.
The first line contains an integer $$$T$$$ ($$$1 \le T \le 10^5$$$), indicating the number of test cases.
The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 10^5$$$), indicating the number of conditions.
Each of the following $$$n$$$ lines contains three integers $$$t,k,x$$$ ($$$1 \le t \le 2$$$, $$$1 \le k \le 10^9$$$, $$$1 \le x \le 10^{9}$$$), indicating a condition.
It is guaranteed that $$$\sum n \le 10^5$$$ over all test cases.
For each test case, output an integer in a single line indicating the number of different intervals that satisfy the conditions. If there are an infinite number of intervals, output $$$-1$$$ in a single line.
421 1 22 1 421 1 42 1 221 1 12 1 142 1 151 5 201 3 82 2 25
4 -1 0 7
For the first test case of the sample, there are two conditions:
There are four intervals that satisfy the conditions: $$$[1,2]$$$, $$$[1,3]$$$, $$$[2,2]$$$ and $$$[2,3]$$$.
For the second test case of the sample, there are two conditions:
All intervals with $$$3 \le l \le 4$$$ and $$$r \ge 4$$$ satisfy the conditions, so there are an infinite number of intervals.
$$$\quad$$$
Here is a reference picture of the I Wanna level:
| Name |
|---|


