eolymp
bolt
Try our new interface for solving problems
Problems

Grid with equal xor

Grid with equal xor

Time limit 1 second
Memory limit 128 MiB

Given an integer n which is a multiple of 4. Find an n x n grid for which the bitwise xor of every row and every column is the same. Each number from 0 to n^2 - 1 must appear in the grid exactly once.

Input data

One integer n (1n1000) which is a multiple of 4.

Output data

Print an n x n grid with numbers from 0 to n^2 - 1 for which the bitwise xor of every row and column is the same. If there are multiple solutions, print any.

Examples

Input example #1
4
Output example #1
0 1 2 3 
4 5 6 7 
8 9 10 11 
12 13 14 15