#include #include using namespace std; int par(int x,vector& p) { if(x == p[x])return x; else return p[x] = par(p[x],p); } long long gcd(long long a,long long b) { if(b)return gcd(b,a%b); else return a; } int main() { int N,M,t; cin >> N >> M; vector p(N); for(int i=0;i> t; vector s(t); for(int j=0;j> s[j]; int tt = p[s[t-1]-1]; for(int j=t-1;j>0;j--)p[s[j]-1] = p[s[j-1]-1]; p[s[0]-1] = tt; } vector pa(N),c(N,0); for(int i=0;i