import java.util.Arrays; import java.util.Scanner; public class Yukicoder101 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int[][] xy = new int[k + 1][2]; for (int i = 0; i < k; i++) { xy[i + 1][0] = sc.nextInt(); xy[i + 1][1] = sc.nextInt(); } int[] loop = new int[n + 1]; Arrays.fill(loop, 1); int pos, res = 1; for (int l = 1; l <= n; l++) { pos = l; for (int i = 1; i <= n; i++) { for (int j = 1; j <= k; j++) { if (xy[j][0] == pos) { pos = xy[j][1]; } else if (xy[j][1] == pos) { pos = xy[j][0]; } } if (l == pos) { loop[l] = i; break; } } } res = loop[1]; for (int i = 2; i <= n; i++) { res = lcm(res, loop[i]); } System.out.println(res); } static int gcd(int n, int m) { int r = n % m; if (r == 0) return m; else return gcd(m, r); } static int lcm(int n, int m) { return n / gcd(n, m) * m; } }