import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void find(int a,int b,int x,int y,int count,int m[][],int n) { if(x==n-1 && y==n-1) { m[x][y]=count; return ; } if((x+a)>=0 && (x+a)=0 && (y+b)(count+1)) { m[x+a][y+b]=count+1; find(a,b,x+a,y+b,count+1,m,n); } } if((y-b)>=0 && (y-b)(count+1)) { m[x+a][y-b]=count+1; find(a,b,x+a,y-b,count+1,m,n); } } } if((x-a)>=0 && (x-a)=0 && (y+b)(count+1)) { m[x-a][y+b]=count+1; find(a,b,x-a,y+b,count+1,m,n); } } if((y-b)>=0 && (y-b)(count+1)) { m[x-a][y-b]=count+1; find(a,b,x-a,y-b,count+1,m,n); } } } if((x+b)>=0 && (x+b)=0 && (y+a)(count+1)) { m[x+b][y+a]=count+1; find(a,b,x+b,y+a,count+1,m,n); } } if((y-a)>=0 && (y-a)(count+1)) { m[x+b][y-a]=count+1; find(a,b,x+b,y-a,count+1,m,n); } } } if((x-b)>=0 && (x-b)=0 && (y+a)(count+1)) { m[x-b][y+a]=count+1; find(a,b,x-b,y+a,count+1,m,n); } } if((y-a)>=0 && (y-a)(count+1)) { m[x-b][y-a]=count+1; find(a,b,x-b,y-a,count+1,m,n); } } } } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int m[][]=new int[n][n]; int q[][]=new int[n-1][n-1]; for(int i=1;i