#P8026. [ONTAK2015] Bajtocja
[ONTAK2015] Bajtocja
Problem Description
You are given undirected graphs, each with vertices. Initially, there are no edges in any graph. Then there are operations. Each operation gives , meaning that an undirected edge is added between vertex and vertex in the -th graph. After each operation, you need to output the number of ordered pairs such that , and vertices and are connected in all graphs.
Input Format
The first line contains three integers .
The next lines each contain three integers .
Output Format
Output lines. Each line contains one integer, representing the required value.
3 4 10
1 2 1
2 1 2
1 2 3
3 4 1
1 3 2
2 3 3
2 4 2
3 4 3
3 4 2
1 3 1
4
4
6
6
6
6
6
8
8
16
Hint
For of the testdata, , , , , .
Translated by ChatGPT 5