import java.util.*;

public class e2q8 {

	public static void main(String[] args) {
	
		for (int i=0; i<8; i++) {
			for (int j=0; j<8; j++) 
				System.out.print(path(3, 0, 0, i, j)+" ");
			System.out.println();
		}
	
	}

	public static String path(int n, int sR, int sC, int r, int c) {
	
		// Here's the math for solving the base case.
		if (n == 1) 
			return new String(""+(2*(r-sR)+(c-sC)));
		
		int div = 1<<(n-1);
		int thisMove = 2*((r-sR)/div) + (c-sC)/div;
		int offR = div*((r-sR)/div);
		int offC = div*((c-sC)/div);
		
		// Get rest of the path.
		String rest = path(n-1, sR + offR , sC + offC, r, c);
		
		// Pre-pend with first move and return.
		return thisMove + rest;
	}
}