import java.io.*; import java.util.*; public class PixelShuffle_nomura{ static int gcd(int a,int b){ return b==0 ? a : gcd(b,a%b); } static int lcm(int a,int b){ return a/gcd(a,b)*b; } public static void main(String[] args) throws Exception{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st; int i,j,k,l; while(true){ int n=Integer.parseInt(br.readLine()); if(n==0) break; int[][] trans=new int[n][n]; for(i=0;i