#define _USE_MATH_DEFINES #include #include #include #include #include //#include #include #include #include #include #include #include ///////// #define REP(i, x, n) for(int i = x; i < n; i++) #define rep(i,n) REP(i,0,n) #define P(p) cout<<(p)< ///////// typedef long long LL; typedef long double LD; ///////// using namespace::std; ///////// int gcd(int a,int b){ while( b != 0 ){ a = a % b; swap(a,b); } return a; } int main(void){ std::cin.tie(0); std::ios::sync_with_stdio(false); std::cout << std::fixed;// //cout << setprecision(10);// int N,K;cin>>N>>K; int s[100]; int tra[100]; rep(i,N)s[i]=i; int X,Y; rep(i,K){ cin>>X>>Y; swap(s[X-1],s[Y-1]); } rep(i,N){ tra[ s[i] ] = i; } int Now[100]; int count = 1,tcount; rep(i,N){ Now[i] = i; } rep(i,N){ tcount=0; do{ ++tcount; Now[i] = tra[ Now[i] ]; }while(Now[i]!=i); count = count/gcd(count,tcount)*tcount; } P(count); return 0; }