/* - At first, the program generates graphs of all sizes from 10 to 50 - To ensure the graph is connected, start with a ring graph - Just increase the degree of each node by 2 by adding edges randomly - Sometimes it might be stuck where it can't add anymore edges without creating parallel edges, but some nodes don't have a degree of 4 - Just maintain a counter and restart when too many iterations happen without adding edges - If A is the adjacency matrix, (A^k)[i][j] gives the number of paths from i to j with k edges - If the rows and columns of A were permuted into B, B^k would also be permuted the same way - To find the permutation, sort every row A^k and B^k and just try to match each row in A with each row in B - This won't work if the rows aren't distinct after sorting, just choose a different k or regenerate a graph */ import java.io.*; import java.util.*; public class Solution { static final Reader in = new Reader(); static final PrintWriter out = new PrintWriter(System.out); public static void main(String[] args) { long[][][] mats=new long[41][][]; int[] pow = new int[41]; for(int ti=10; ti<=50; ++ti) { mats[ti-10] = new long[ti][ti]; for(int i=0; i0) out.println((i+1)+" "+(j+1)); out.flush(); long[][] mat1 = new long[l][l], mat2 = new long[l][l], mat3 = new long[l][l]; in.nextInt(); for(int i=0; i