#include using namespace std; #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) using ll = long long; using P = std::tuple; const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1}; int N, M, Q; P bridges[200000], brokenBridges[200000]; bool isBroken[200000]; int res[100000]; std::vector> groups; std::vector members; // group number of each member void init(int n){ groups.resize(n); members.resize(n); for(int i=0;i groups[v].size()){ std::swap(u, v); } for(int w : groups[u]){ members[w] = v; // printf("%d, ", w); } // puts(""); groups[v].insert(groups[v].end(), groups[u].begin(), groups[u].end()); groups[u].clear(); } bool same(int u, int v){ return members[u] == members[v]; } int main(){ //* std::cin.tie(nullptr); std::ios::sync_with_stdio(false); /*/ /*/ scanf("%d %d %d", &N, &M, &Q); init(N); for(int i=0;i=0;--i){ int u, v; tie(u, v) = brokenBridges[i]; // printf("Phase: %d, %d, %d\n", i, members[u], members[v]); // for(int i=0;i