public class sample1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
List<int[]> outer = new ArrayList<int[]>(9);
List<int[]> inner = new ArrayList<int[]>(9);
int[][] final_arr = new int[9][18];
int[][][] final_arr2 = new int[6][3][9];
int[][] multi = new int[][]{
{2,3,5,7,9,12,13,15,17},
{1,3,4,5,6,7,11,14,16,18},
{1,2,4,6,8,9,12,13,17,18},
{3,5,7,9,10,11,12,14,15,16},
{1,4,6,7,8,10,11,13,14,18},
{2,3,5,8,9,12,13,15,16,17},
{1,2,4,6,7,10,11,13,17,18},
{1,3,5,8,9,12,13,15,16,18},
{2,4,6,7,9,10,11,14,15,16,17}
};
for( int i=0;i<9;i++){
outer.add(multi[i]);
}
for(int x=0;x<9;x++){
int [] temp = new int[18];
for(int k=0;k<outer.get(x).length;k++){
//System.out.print(outer.get(x)[k]-1 +" ");
int row = outer.get(x)[k]-1;
temp[row]=1;
}
//System.out.println();
inner.add(temp);
}
System.out.println();
int count=1;
for(int i=0;i<9;i++){
List<Integer> temp = new ArrayList<Integer>();
for(int k=0;k<outer.get(i).length;k++){
temp.add(count);
count++;
}
Collections.shuffle(temp);
int index_of_temp=0;
for(int j=0;j<18;j++){
if(inner.get(i)[j]==1){
inner.get(i)[j]=temp.get(index_of_temp);
index_of_temp++;
}
//System.out.print(inner.get(i)[j]+ " ");
}
//System.out.println();
}
for(int i=0;i<9;i++){
for(int j=0;j<18;j++){
final_arr[i][j]=inner.get(i)[j];
}
}
System.out.println();
for(int i=0;i<18;i++){
for(int j=0;j<9;j++){
//System.out.print(final_arr[j][i]+ " ");
final_arr2[i/3][i%3][j]=final_arr[j][i];
}
}
for(int k=0;k<6;k++){
for(int i=0;i<3;i++){
for(int j=0;j<9;j++){
System.out.print(final_arr2[k][i][j]+ " ");
}
System.out.println();
}
System.out.println();
}
}
}