#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x>N>>K; FOR(i,N) R[i]=i; while(K--) { cin>>x>>y; swap(R[x-1],R[y-1]); } ll ret=1; FOR(i,N) { x=i; for(x=i,y=0;y==0 || x!=i;y++) { x=R[x]; } ret=ret*y/__gcd(ret,(ll)y); } cout<