DreamGrid has just found an undirected simple graph with $n$ vertices and no edges (that's to say, i

DreamGrid has just found an undirected simple graph with n n n vertices and no edges (that’s to say, it’s a graph with n n n isolated vertices) in his right pocket, where the vertices are numbered from 1 to n n n. Now he would like to perform q q q operations of the following two types on the graph:

1 a b – Connect the a a a-th vertex and the b b b-th vertex by an edge. It’s guaranteed that before this operation, there does not exist an edge which connects vertex a a a and b b b directly.
2 k – Find the answer for the query: What’s the minimum and maximum possible number of connected components after adding k k k new edges to the graph. Note that after adding the k k k edges, the graph must still be a simple graph, and the query does NOT modify the graph.
Please help DreamGrid find the answer for each operation of the second type. Recall that a simple graph is a graph with no self loops or multiple edges.

Input
There are multiple test cases. The first line of the input is an integer T T T, indicating the number of test cases. For each test case:

The first line contains two integers n n n and q q q ( 1 ≤ n ≤ 1 0 5 1 \le n \le 10^5 1n105, 1 ≤ q ≤ 2 × 1 0 5 1 \le q \le 2 \times 10^5 1q2×105), indicating the number of vertices and the number of operations.

For the following q q q lines, the i i i-th line first contains an integer p i p_i pi ( p i ∈ { 1 , 2 } p_i \in \{1, 2\} pi{1,2}), indicating the type of the i i i-th operation.

If p i = 1 p_i = 1 pi=1, two integers a i a_i ai and b i b_i bi follow ( 1 ≤ a i , b i ≤ n 1 \le a_i, b_i \le n 1ai,bin, a i ≠ b i a_i \ne b_i ai=bi), indicating an operation of the first type. It’s guaranteed that before this operation, there does not exist an edge which connects vertex a a a and b b b directly.
If p i = 2 p_i = 2 pi=2, one integer k i k_i ki follows ( 0 ≤ k i ≤ n ( n − 1 ) 2 0 \le k_i \le \frac{n(n-1)}{2} 0ki2n(n1)), indicating an operation of the second type. It’s guaranteed that after adding k i k_i ki edges to the graph, the graph is still possible to be a simple graph.
It’s guaranteed that the sum of n n n in all test cases will not exceed 1 0 6 10^6 106, and the sum of q q q in all test cases will not exceed 2 × 1 0 6 2 \times 10^6 2×106.

Output
For each operation of the second type output one line containing two integers separated by a space, indicating the minimum and maximum possible number of connected components in this query.

Sample Input
1
5 5
1 1 2
2 1
1 1 3
2 1
2 3
Sample Output
3 3
2 3
1 2

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值