You are given a directed graph with $$$n$$$ vertices, numbered from $$$1$$$ to $$$n$$$. The graph is constructed as follows: for each vertex $$$i$$$ from $$$2$$$ to $$$n$$$, you are given two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i \le r_i \lt i$$$). For each integer $$$j \in [l_i, r_i]$$$, the graph contains a directed edge from $$$j$$$ to $$$i$$$. There are no other edges in the graph.
Consider a second directed graph on the same $$$n$$$ vertices. For any two distinct vertices $$$x$$$ and $$$y$$$, a path from $$$x$$$ to $$$y$$$ must exist in the second graph if and only if it exists in the first graph.
Find the minimum possible number of edges in the second graph.
The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.
The first line of each test case contains one integer $$$n$$$ ($$$2 \le n \le 3 \cdot 10^5$$$) — the number of vertices.
The next $$$n-1$$$ lines describe the edges of the graph. The $$$i$$$-th of these lines contains two integers $$$l_{i+1}$$$ and $$$r_{i+1}$$$ ($$$1 \le l_{i+1} \le r_{i+1} \le i$$$).
Additional constraints on the input:
For each test case, print one integer — the minimum possible number of edges in the second graph.
551 11 22 32 461 11 12 32 34 551 11 21 31 461 11 11 12 42 461 11 21 12 43 5
48496
In the first test case, you can add the edges $$$1 \to 2$$$, $$$2 \to 3$$$, $$$3 \to 4$$$, and $$$4 \to 5$$$ to the second graph.
In the second test case, you can add the edges $$$1 \to 2$$$, $$$1 \to 3$$$, $$$2 \to 4$$$, $$$3 \to 4$$$, $$$2 \to 5$$$, $$$3 \to 5$$$, $$$4 \to 6$$$, and $$$5 \to 6$$$ to the second graph.
| Name |
|---|


