module main; import std; void main() { // 入力 int N = readln.chomp.to!int; int K = readln.chomp.to!int; auto X = new int[](K), Y = new int[](K); foreach (ref x, ref y; lockstep(X, Y)) { readln.chomp.formattedRead("%d %d", x, y); --x, --y; } // 答えの計算と出力 if (K == 0) { writeln(1); return; } auto A = iota(0, N).array; int ans = 0; do { foreach (x, y; lockstep(X, Y)) swap(A[x], A[y]); ++ans; } while (!equal(A, iota(0, N))); writeln(ans); }