public class Cavalier {
    public static void main(String []a) {
	int [][]echiquier = new int[8][8];
	if (calcul(echiquier,3,7,0)) {
	    printec(echiquier);
	}
    }
    public static void printec(int [][]echiquier) {
	    for (int i=0; i<8; i++) {
		for (int j=0; j<8; j++) {
		    System.out.print(echiquier[i][j]+" ");
		}
	    System.out.println();
	    }
	    System.out.println();
    }
    public static boolean calcul(int [][]t,int x,int y,int n) {
	//	printec(t);
	//	System.out.println(n);
	if (x<0 || x>7) return false;
	if (y<0 || y>7) return false;
	if (t[x][y]!=0) return false;
	n++;
	t[x][y] = n;
	if (n==64) return true;
	if (calcul(t,x-2,y-1,n)) return true;
	if (calcul(t,x-2,y+1,n)) return true;
	if (calcul(t,x-1,y-2,n)) return true;
	if (calcul(t,x-1,y-2,n)) return true;
	if (calcul(t,x+1,y-2,n)) return true;
	if (calcul(t,x+1,y+2,n)) return true;
	if (calcul(t,x+2,y-1,n)) return true;
	if (calcul(t,x+2,y-1,n)) return true;
	t[x][y] = 0;
	return false;
    }
}