import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; class Pair { public int dimension_1,dimension_2; public Pair(int x,int y) { dimension_1=x; dimension_2=y; } public boolean equals(Object o) { Pair e=(Pair)o; return this.dimension_1==e.dimension_1&&this.dimension_2==e.dimension_2; } public int hashCode() { return this.dimension_1+this.dimension_2; } } public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int a,b,loop=0,flag=0; int [][]matrix=new int[n][n]; for(int j=0;j old_list=new HashSet<>(); Set new_list=new HashSet<>(); Set oldtill_list=new HashSet<>(); for(int i=1;i<=n-1;i++) { for(int j=1;j<=i;j++) { loop=0; flag=0; while(true) { Pair e1=new Pair(0,0); oldtill_list.add(new Pair(n-1,n-1)); if(flag==0) { loop++; if((a+i)=0&&(b+j)>=0) old_list.add(new Pair(a+i,b+j)); if((a+j)=0&&(b+i)>=0) old_list.add(new Pair(a+j,b+i)); if((a-i)=0&&(b-j)>=0) old_list.add(new Pair(a-i,b-j)); if((a-j)=0&&(b-i)>=0) old_list.add(new Pair(a-j,b-i)); if((a-i)=0&&(b+j)>=0) old_list.add(new Pair(a-i,b+j)); if((a-j)=0&&(b+i)>=0) old_list.add(new Pair(a-j,b+i)); if((a+i)=0&&(b-j)>=0) old_list.add(new Pair(a+i,b-j)); if((a+j)=0&&(b-i)>=0) old_list.add(new Pair(a+j,b-i)); if(old_list.contains(e1)) { matrix[i][j]=loop; matrix[j][i]=loop; break; } oldtill_list.addAll(old_list); flag=1; } else { loop++; Iterator itr= old_list.iterator(); while(itr.hasNext()) { Pair e=(Pair)itr.next(); if((e.dimension_1+j)=0&&(e.dimension_2-i)>=0) { new_list.add(new Pair(e.dimension_1+j,e.dimension_2-i)); if((e.dimension_1+j)==0 && (e.dimension_2-i)==0) { matrix[i][j]=loop; break; } } if((e.dimension_1-j)=0&&(e.dimension_2+i)>=0){ new_list.add(new Pair(e.dimension_1-j,e.dimension_2+i)); if((e.dimension_1-j)==0 && (e.dimension_2+i)==0) { matrix[i][j]=loop; break; } } if((e.dimension_1+j)=0&&(e.dimension_2+i)>=0){ new_list.add(new Pair(e.dimension_1+j,e.dimension_2+i)); if((e.dimension_1+j)==0 && (e.dimension_2+i)==0) { matrix[i][j]=loop; break; } } if((e.dimension_1-j)=0&&(e.dimension_2-i)>=0){ new_list.add(new Pair(e.dimension_1-j,e.dimension_2-i)); if((e.dimension_1-j)==0 && (e.dimension_2-i)==0) { matrix[i][j]=loop; break; } } if((e.dimension_1-i)=0&&(e.dimension_2-j)>=0){ new_list.add(new Pair(e.dimension_1-i,e.dimension_2-j)); if((e.dimension_1-i)==0 && (e.dimension_2-j)==0) { matrix[i][j]=loop; break; } } if((e.dimension_1+i)=0&&(e.dimension_2+j)>=0){ new_list.add(new Pair(e.dimension_1+i,e.dimension_2+j)); if((e.dimension_1+i)==0 && (e.dimension_2+j)==0) { matrix[i][j]=loop; break; } } if((e.dimension_1+i)=0&&(e.dimension_2-j)>=0){ new_list.add(new Pair(e.dimension_1+i,e.dimension_2-j)); if((e.dimension_1+i)==0 && (e.dimension_2-j)==0) { matrix[i][j]=loop; break; } } if((e.dimension_1-i)=0&&(e.dimension_2+j)>=0){ new_list.add(new Pair(e.dimension_1-i,e.dimension_2+j)); if((e.dimension_1-i)==0 && (e.dimension_2+j)==0) { matrix[i][j]=loop; break; } } } /* if(new_list.contains(e1)) { matrix[i][j]=loop; matrix[j][i]=loop; break; } */ if(matrix[i][j]==loop) { matrix[j][i]=loop; break; } new_list.removeAll(oldtill_list); if(new_list.isEmpty()) { matrix[i][j]=-1; matrix[j][i]=-1; break; } oldtill_list.addAll(new_list); old_list.clear(); old_list.addAll(new_list); new_list.clear(); } } old_list.clear(); new_list.clear(); oldtill_list.clear(); } } /* for(int i=4;i<=n-1;i++) { for(int j=4;j<=i;j++) { if(i==n-1&&j==n-1) matrix[i][j]=1; else { matrix[i][j]=-1; matrix[j][i]=-1; } } }*/ for(int i=1;i<=n-1;i++) { for(int j=1;j<=n-1;j++) { System.out.print(matrix[i][j]+" "); } System.out.print("\n"); } } }