#include #define int long long using namespace std; inline int read() { int x=0,f=1;char ch=getchar(); while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();} while (ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-48;ch=getchar();} return x*f; } void write(int x) { if(x<0)putchar('-'),x=-x; if(x<10)putchar(x+'0'); else write(x/10),putchar(x%10+'0'); } const int N=6e5; const int mod=1e9+7; int n,m,q; int ans[N]; int f[N]; struct node{ int u,v; }mp[N],a[N]; vectorg[N]; sets[N]; setss[N]; int root(int x){ if(f[x]==x)return x; int k=root(f[x]); for(int i=0;i=1;i--){ int x=root(a[i].u); int y=root(a[i].v); int ff=root(1); f[root(x)]=root(y); fa=root(1); if(root(a[i].u)==fa){ int z=fa; if(!ans[z]) ans[z]=i; for(int j=0;j