Жишээ тэстүүд

Оролт
5 2
2 1
4 3
2 4
2 5
4 1
5 4
1 5
Гаралт
3
3
Оролт
6 2
4 6
4 3
1 2
6 5
1 5
1 4
2 5
2 6
Гаралт
4
3

Тэмдэглэл

Let's consider the first sample. We'll highlight the switched on edges blue on the image.

  • The graph before applying any operations. No graph edges are switched on, that's why there initially are 5 connected components.

* The graph after query $v = 5, u = 4$. We can see that the graph has three components if we only consider the switched on edges.

* The graph after query $v = 1, u = 5$. We can see that the graph has three components if we only consider the switched on edges.

Lexicographical comparison of two sequences of equal length of $k$ numbers should be done as follows. Sequence $x$ is lexicographically less than sequence $y$ if exists such $i$ ($1 ≤ i ≤ k$), so that $x_{i} < y_{i}$, and for any $j$ ($1 ≤ j < i$) $x_{j} = y_{j}$.