#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair i_i; typedef pair ll_i; typedef pair d_i; typedef pair ll_ll; typedef pair d_d; struct edge { int u, v; ll w; }; ll MOD = 1000000007; ll _MOD = 1000000009; double EPS = 1e-10; int a[4][4] = { {1, 0, 0, 1}, {0, 1, 1, 0}, {0, 1, 1, 0}, {1, 0, 0, 1} }; int main() { int N, X, Y, Z; cin >> N >> X >> Y >> Z; X--; Y--; Z--; vector > b(N, vector(N)); for (int y = 0; y < N; y++) for (int x = 0; x < N; x++) if (a[y % 4][x % 4]) b[y][x] = y * N + x; else b[y][x] = N * N - 1 - y * N - x; int z = b[Y][X]; for (int y = 0; y < N; y++) { for (int x = 0; x < N; x++) { b[y][x] ^= Z ^ z; cout << b[y][x] + 1 << ' '; } cout << endl; } }