import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.NoSuchElementException; import java.util.TreeMap; class Main { public static void main(String[] args) { new Main().run(); } int MAX=(int)1e5+1; boolean[] isPrime=new boolean[MAX]; ArrayList primes=new ArrayList<>(); ArrayList>[] pe=new ArrayList[MAX]; { for (int i=0;i(); Arrays.fill(isPrime, true); isPrime[0]=isPrime[1]=false; for (int i=2;ii) isPrime[j]=false; int e=0; int v=j; while (v%i==0) { v/=i; ++e; } pe[j].add(List.of(i, e)); } } } HashMap> cyclic_group(int n) { HashMap> decode=new HashMap<>(); for (var pair : pe[n]) { int p=pair.get(0); int e=pair.get(1); if (p != 2) { if (e >= 2) decode.computeIfAbsent(p, key -> new ArrayList<>()).add(e-1); for (var pair2 : pe[p-1]) { int p2=pair2.get(0); int e2=pair2.get(1); decode.computeIfAbsent(p2, key -> new ArrayList<>()).add(e2); } } else { if (e == 2) { decode.computeIfAbsent(p, key -> new ArrayList<>()).add(1); } else if (e >= 3){ decode.computeIfAbsent(p, key -> new ArrayList<>()).add(e-2); decode.computeIfAbsent(p, key -> new ArrayList<>()).add(1); } } } return decode; } void normalize(int[][] key) { for (int i=0;i() { @Override public int compare(int[] o1, int[] o2) { for (int i=0;i set=new TreeMap<>(new Comparator() { @Override public int compare(int[][] o1, int[][] o2) { for (int i=0;i set=new TreeMap<>(new Comparator() { @Override public int compare(int[] o1, int[] o2) { for (int i=0;i