E Making Connections
题号:NC223926
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述


输入描述:

The first input line contains two space separated integers: n (1 ≤ n ≤ 105), representing the number of computers, and m (1 ≤ m ≤ 3×105), representing the total number of steps (each step being either


connect two computers or a query on the average connectivity as of that moment). Assume that the computers are numbered 1 throughn, inclusive.

 

Each of the following m input lines contains information about one operation, in the order that they occur. Each of these lines will start with a single integer, either 1 or 2, providing the step type. If the step type is 1, it means that a pair of computers is being connected with a direct connection. The value of 1 will be followed by u and v (1 ≤u, v ≤ n, u≠ v), representing the pair of computers being connected with a direct connection. If the step type is 2, this is a query and no other information will be on that input line.

 

Note: It’s possible that the input contains multiple direct connections for the same pair of computers; the extra direct connections between the same two computers do not have any effects. It’s also possible that, at the end of the process, not allncomputers are connected in the same component, i.e., there may be more than one component even at the end of the process.

输出描述:

For each query, output the average connectivity of the network at that point in time as a fraction in lowest terms on a line by itself. Specifically, output two integers,xandy, with the character ‘/’ in between, indicating that the average connectivity of the network at the time isxdivided byysuch thatxandyshare no common factors, e.g., 21/12 is not correct (should be 7/4).

示例1

输入

复制
7 9
2 
1 1 2
1 1 3
2 
1 3 4
1 2 3
2 
1 6 7
2

输出

复制
1/1
13/5
19/4
7/1
示例2

输入

复制
4 9
1 1 2
2 
1 3 4
2 
1 2 3
2 
1 1 4
1 2 4
2

输出

复制
2/1
4/1
16/1
16/1