#include #include #include using namespace atcoder; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 100000000000 int main(){ int N; cin>>N; vector a(N); rep(i,N)a[i] = i; int K; cin>>K; rep(i,K){ int x,y; cin>>x>>y; swap(a[x],a[x-1]); } dsu D(N); rep(i,N){ D.merge(i,a[i]); } long long ans = 1LL; rep(i,N){ ans = lcm(ans,(long long)D.size(i)); } cout<