// Author : Choudhary Reyan Khan
#include <bits/stdc++.h>
using namespace std;
int main() {
int row = 6, col = 7;
int mat[row][col];
map<int,int> mp;
map<int,int> str;
for(int i=0;i<row;i++){
for(int j=0;j<col;j++){
mat[i][j]=i-j;
mp[i-j]++;
}
}
int x = row-1;
int y = 0-(col-1);
int c=1, cnt=0, tmp=1;
for(int i=x;i>=y;i--){
str[i]=c;
if(cnt&1) str[i]+=(mp[i]-1);
c+=mp[i];
cnt++;
}
for(int i=0;i<row;i++){
for(int j=0;j<col;j++){
cout << str[mat[i][j]] << "\t";
if(row&1){
if(mat[i][j]&1) str[mat[i][j]]--;
else str[mat[i][j]]++;
}
else{
if(mat[i][j]&1) str[mat[i][j]]++;
else str[mat[i][j]]--;
}
}
cout << "\n";
}
return 0;
}
Ly8gQXV0aG9yIDogQ2hvdWRoYXJ5IFJleWFuIEtoYW4KCgojaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkgewogICAgaW50IHJvdyA9IDYsIGNvbCA9IDc7CiAgICBpbnQgbWF0W3Jvd11bY29sXTsKICAgIG1hcDxpbnQsaW50PiBtcDsKICAgIG1hcDxpbnQsaW50PiBzdHI7CiAgICBmb3IoaW50IGk9MDtpPHJvdztpKyspewogICAgICAgIGZvcihpbnQgaj0wO2o8Y29sO2orKyl7CiAgICAgICAgICAgIG1hdFtpXVtqXT1pLWo7CiAgICAgICAgICAgIG1wW2ktal0rKzsKICAgICAgICB9CiAgICB9CiAgICBpbnQgeCA9IHJvdy0xOwogICAgaW50IHkgPSAwLShjb2wtMSk7CiAgICBpbnQgYz0xLCBjbnQ9MCwgdG1wPTE7CiAgICBmb3IoaW50IGk9eDtpPj15O2ktLSl7CiAgICAgICAgc3RyW2ldPWM7CiAgICAgICAgaWYoY250JjEpIHN0cltpXSs9KG1wW2ldLTEpOwogICAgICAgIGMrPW1wW2ldOwogICAgICAgIGNudCsrOwogICAgfQogICAgZm9yKGludCBpPTA7aTxyb3c7aSsrKXsKICAgICAgICBmb3IoaW50IGo9MDtqPGNvbDtqKyspewogICAgICAgICAgICBjb3V0IDw8IHN0clttYXRbaV1bal1dIDw8ICJcdCI7CiAgICAgICAgICAgIGlmKHJvdyYxKXsKICAgICAgICAgICAgICAgIGlmKG1hdFtpXVtqXSYxKSBzdHJbbWF0W2ldW2pdXS0tOwogICAgICAgICAgICAgICAgZWxzZSBzdHJbbWF0W2ldW2pdXSsrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2V7CiAgICAgICAgICAgICAgICBpZihtYXRbaV1bal0mMSkgc3RyW21hdFtpXVtqXV0rKzsKICAgICAgICAgICAgICAgIGVsc2Ugc3RyW21hdFtpXVtqXV0tLTsKICAgICAgICAgICAgfQogICAgICAgICAgICAKICAgICAgICB9CiAgICAgICAgY291dCA8PCAiXG4iOwogICAgfQoKCiAgICByZXR1cm4gMDsKfQo=