Timur's grandfather gifted him a chessboard to practice his chess skills. This chessboard is a grid $$$a$$$ with $$$n$$$ rows and $$$m$$$ columns with each cell having a non-negative integer written on it. Timur's challenge is to place a bishop on the board such that the sum of all cells attacked by the bishop is maximal. The bishop attacks in all directions diagonally, and there is no limit to the distance which the bishop can attack. Note that the cell on which the bishop is placed is also considered attacked. Help him find the maximal sum he can get.

The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The description of test cases follows. The first line of each test case contains the integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 200$$$, $$$1 \leq m \leq 200$$$). The following $$$n$$$ lines contain $$$m$$$ integers each, the $$$j$$$-th element of the $$$i$$$-th line $$$a_{ij}$$$ is the number written in the $$$j$$$-th cell of the $$$i$$$-th row $$$(0\leq a_{ij} \leq 10^6)$$$ It is guaranteed that the sum of $$$n\cdot m$$$ over all test cases does not exceed $$$4\cdot10^4$$$.

For each test case output a single integer, the maximum sum over all possible placements of the bishop.

NoteFor the first test case here the best sum is achieved by the bishop being in this position:

const { createInterface } = require('readline');
const { createWriteStream, createReadStream } = require('fs');
const { format } = require('util');

function calcDiags(t, n, m, init) {
  const { i, j } = init

  //from top left to bottom right
  let sum1 = 0
  let j1 = (j > i) ? j - i : 0
  let i1 = (j > i) ? 0 : i - j
  //console.log({ j1, i1 })

  for (let i = i1, j = j1; i < n && j < m; i++, j++) {
    sum1 += t[i][j]
  }

  //from top right to bottom left
  let sum2 = 0
  let diff_j_m = (m - 1) - j
  let diff_i_0 = i - 0
  let min_diff = Math.min(diff_j_m, diff_i_0)

  let j2 = j + min_diff
  let i2 = i - min_diff
  //console.log({ j2, i2 })

  for (let i = i2, j = j2; i < n && j >= 0; i++, j--) {
    sum2 += t[i][j]
  }

  //all

  const sum = sum1 + sum2 - t[i][j]
  //console.log({ sum1, sum2, sum })
  return sum
}

function getMax(t, n, m) {
  let max = 0
  // console.log({ n, m })
  //console.log("\n")
  //console.log(getTable(t))

  for (let i = 0; i < n; i++) {
    for (let j = 0; j < m; j++) {
      const calc = calcDiags(t, n, m, { i, j })
      if (max < calc) {
        max = calc
      }
    }
  }
  return max

}

const max = Number.MAX_SAFE_INTEGER

function main() {
  const readline = createInterface({
    input: process.stdin,
    output: process.stdout
  });
  let lineNb = 0;
  let subLine = 0;
  let n;
  let isCollecting = true;
  let subN;
  let subM;
  let t = [];
  readline.on('line', line => {
    if (!lineNb) {
      lineNb = 1;
      n = parseInt(line);
    }
    else {
      const data = line.split(" ").map(function (item) {
        return parseInt(item, 10);
      })
      if (data.length == 2 && isCollecting) {
        isCollecting = false
        n--
        subLine = 0;
        t = []
        subN = data[0]
        subM = data[1]
      } else {
        subLine++;
        t.push(data)
        if (subLine == subN) {
          console.log(getMax(t, subN, subM))
          isCollecting = true
          if (!n) {
            readline.close()
          }
        }
      }
    }

  });

}

main()

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = nextLong();
		}else if(code == 'double'){
			ret[i] = nextDouble();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');} function nextDoubleArray(size){return nextArray(size, 'double');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());} function nextDouble(){return parseFloat(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	var d = [[-1,-1],[-1,1],[1,-1],[1,1]];
	while(hasNext()){
		var H = nextInt();
		var W = nextInt();
		var list = new Array(H);
		for(var i = 0; i < H; i++){
			list[i] = nextIntArray(W);
		}
		var output = 0;
		for(var i = 0; i < H; i++){
			for(var j = 0; j < W; j++){
				var sum = list[i][j];
				for(var k = 0; k < d.length; k++){
					var nxY = i + d[k][0];
					var nxX = j + d[k][1];
					while(nxY >= 0 && nxY < H && nxX >= 0 && nxX < W){
						sum += list[nxY][nxX];
						nxY += d[k][0];
						nxX += d[k][1];
					}
				}
				output = Math.max(output, sum);
			}
		}
		myout(output);
	}
}

/*
File Created: Tuesday, 17 May 2022
Author: Lukas Rimkus
*/
'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let data = '';
let currentLine = 0;

process.stdin.on('data', chunk => {
     data += chunk;
});
process.stdin.on('end', () =>{
    data = data.replace(/\s*$/, '').split('\n').map(str => str.replace(/\s*$/, ''));
    let testCases = parseInt(readLine());
    while(testCases--) {
        const [n,m] =  get_ints();
        const arr = [];
        for (let index = 0; index < n; index++) {
            arr.push(readLine().split(' ').map(x=>Number(x)))
        }
        console.log(solve([n,m,arr]));
    }
});
function get_ints() {
    return data[currentLine++].split(' ').map(x=>Number(x));
}

function readLine() {
    return data[currentLine++];
}

function solve(input){
    let res = 0;
    for (let row = 0; row < input[0]; row++) {
        for(let col = 0; col < input[1]; col++){
            const sum = calcDiagonalSum(input[0],input[1],row,col, input[2]);
            if(sum > res){
                res = sum;
            }
        }
    }
    return res;
}

function calcDiagonalSum(rows,cols,currRow,currCol, array){
    let sum = array[currRow][currCol];
    // console.log('rows,cols,currRow,currCol, array',array[currRow][currCol])
    let j = currCol + 1;
    for(let i = currRow + 1; i < rows; i++){
        if(!isNaN(array[i][j])) sum+=array[i][j];
        j++;
    }
    // calc right, top
    j = currCol + 1;
    for (let i = currRow - 1; i >= 0; i--) {
        if(!isNaN(array[i][j])) sum+=array[i][j];
        j++;
    }
    // calc left, botm
    j = currCol - 1;
    for(let i=currRow + 1; i < rows; i++ ){
        if(!isNaN(array[i][j])) sum+=array[i][j];
        j--;
    }
    // calc left, top
    j = currCol - 1;
    for(let i = currRow - 1; i >= 0; i--){
        if(!isNaN(array[i][j])) sum+=array[i][j];
        j--;
    }

    return sum;
}

module.exports = solve;

const left = (mat, fill, i, j, m, n) => {
  if ((i!=0)&&(fill[i - 1][j - 1])) return (fill[i][j] = fill[i - 1][j - 1]);
  let sum = 0,k=i,l=j;
  while (i < m && j < n) {
    sum += mat[i][j];
    i++;
    j++;
  }
  fill[k][l] = sum;
};
const right = (mat, fill, i, j, m, n) => {
  if ((i!=0)&&(fill[i - 1][j + 1])) return (fill[i][j] = fill[i - 1][j + 1]);
  let sum = 0,k=i,l=j;
  while (i < m && j >= 0) {
    sum += mat[i][j];
    i++;
    j--;
  }
  fill[k][l] = sum;
};

const solve = (m, n, mat) => {
  let lfill = Array.from({ length: m }, () =>
    Array.from({ length: n }, () => 0)
  );
  let rfill = Array.from({ length: m }, () =>
    Array.from({ length: n }, () => 0)
  );
  let max = -Infinity;
  for (let i = 0; i < m; i++) {
    for (let j = 0; j < n; j++) {
      left(mat, lfill, i, j, m, n);
      right(mat, rfill, i, j, m, n);
       max = Math.max(lfill[i][j] + rfill[i][j] - mat[i][j], max);
    }
  }
  return max;
};
function main() {
  const fs = require("fs");
  const input = fs.readFileSync(0, "utf8").trim().split("\n");
  let line = 0;
  function readline() {
    return input[line++];
  }
  let t = parseInt(readline());
  for(let i=0;i<t;i++){
    let [m,n] = readline().trim().split(" ").map(cur=>parseInt(cur));
    let mat = [];
    for(let i=0;i<m;i++){
      mat.push(readline().trim().split(" ").map(cur=>parseInt(cur)));
    }
    console.log(solve(m,n,mat));
  }
}
main();

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

function solve(n, m, a) {
  let res = 0;
  const dirs = [[-1, -1], [1, 1], [-1, 1], [1, -1]];
  for (let i = 0; i < n; i++) {
    for (let j = 0; j < m; j++) {
      let cur = a[i][j];
      for (let [di, dj] of dirs) {
        let x = i + di,
            y = j + dj;
        while (x >= 0 && x < n && y >= 0 && y < m) {
          cur += a[x][y];
          x += di;
          y += dj;
        }
      }
      res = Math.max(res, cur);
    }
  }
  return res.toString();
}

async function main(read) {
  let t = Number(await read());
  let res = [];
  while (t--) {
    const [n, m] = (await read()).split(' ').map(Number);
    const a = [];
    let tmp = n;
    while (tmp--) {
      a.push((await read()).split(' ').map(Number));
    }
    res.push(solve(n, m, a));
  }
  console.log(res.join('\n'));
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
void async function () {
  const inputs = [];
  let i = 0;
  for await (const line of rl) {
    inputs.push(line.trim());
  }
  function read() {
    return inputs[i++];
  }
  await main(read);
}();

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
function readLine() {
    return inputString[currentLine++];
};
process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    main();
    // cmd(not powershell): node cp.js < input.txt
});

function main() {
    let t = parseInt(readLine());
    while (t-- > 0) {
        console.log(solve());
    }
}
function solve() {
    const [n, m] = readLine().split(" ").map(i => parseInt(i));
    let arr = [];
    for (let i = 0; i < n; i++) arr.push(readLine().split(" ").map(j => parseInt(j)));
    return findDiag(arr);
}
function findDiag(arr) {
    let max = 0;
    for (let i = 0; i < arr.length; i++) {
        for (let x = 0; x < arr[i].length; x++) {
            let temp = arr[i][x];
            //t-l
            let j = i - 1;
            let k = x - 1;
            while (j >= 0 && k >= 0) {
                temp += arr[j--][k--];
            }
            //t-r
            j = i - 1;
            k = x + 1;
            while (j >= 0 && k < arr[i].length) {
                temp += arr[j--][k++];
            }
            //b-l
            j = i + 1;
            k = x + 1;
            while (j < arr.length && k < arr[i].length) {
                temp += arr[j++][k++];
            }
            //b-r
            j = i + 1;
            k = x - 1;
            while (j < arr.length && k >= 0) {
                temp += arr[j++][k--];
            }
            max = Math.max(max, temp);
        }
    }
    return max;
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });
  main();
});

function input() {
  return inputString[currentLine++];
}

const dy = [-1, 1, -1, 1];
const dx = [-1, 1, 1, -1];

function main() {
  let tc = parseInt(input());
  while(tc--){
    const [n, m] = input().split(' ').map(Number);
    const a = Array.from(Array(n), () => Array(m));
    for(let i = 0; i < n; i++){
      const tmp = input().split(' ').map(Number);
      for(let j = 0; j < m; j++){
        a[i][j] = tmp[j];
      }
    }
    let ans = 0;
    for(let y = 0; y < n; y++){
      for(let x = 0; x < m; x++){
        ans = Math.max(ans, solve(n, m, a, y, x));
      }
    }
    console.log(ans);
  }
}

const solve = (n, m, a, sy, sx) => {
  let ret = a[sy][sx];
  for(let i = 0; i < 4; i++){
    let y = sy;
    let x = sx;
    while(true){
      y += dy[i];
      x += dx[i];
      if(y < 0 || y >= n || x < 0 || x >= m) break;
      ret += a[y][x];
    }
  }
  return ret;
}

const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trim().split('\r\n');
let currentline = 0;
function readline(){
      return input[currentline++];
}

function alph() {
  var f = 'abcdefghijklmnopqrstuvwxyz';
  return f;
}
function Alph() {
  var f = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  return f;
}
function max(x,y) {
  return x >=y ? x : y;
}
function min(x,y) {
  return x <=y ? x : y;
}
var T = readline();
for(var q=1;q<=T;q++) {
  var [n, m] = readline().split(' ').map((x)=>parseInt(x));
  var a = []
  for(var i=0;i<n;i++) {
    var s = readline().split(' ').map((x)=>parseInt(x));
    a.push(s);
  }
  var tar = -1;
  for(var i=0;i<n;i++) {
    for(var j=0;j<m;j++) {
      var ans = 0;
      var x = i+1, y = j+1;
      while(x<n && y<m) {
        ans += a[x][y];
        x++;
        y++;
      }
      x = i+1;
      y = j-1;
      while(x<n && y>=0) {
        ans += a[x][y];
        x++;
        y--;
      }
      x = i-1;
      y = j+1;

      while(x>=0 && y<m) {
        ans += a[x][y];
        x--;
        y++;
      }
      x = i-1;
      y = j-1;

      while(x>=0 && y>=0) {
        ans += a[x][y];
        x--;
        y--;
      }
      ans += a[i][j]
      tar = max(tar, ans);

    }
  }
  console.log(tar);
  //fs.appendFileSync('output.txt', tar+'\r\n');

  //os.EOL
}
//fs.writeFileSync('output.txt', f.join(' '));

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	// console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = nextLong();
		}else if(code == 'double'){
			ret[i] = nextDouble();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');} function nextDoubleArray(size){return nextArray(size, 'double');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());} function nextDouble(){return parseFloat(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

function Main(){
    // test case in nodeJs
	var t = nextInt();
	while(hasNext()){
		solve();
	}
}

function solve() {
	const rows = nextInt();
    const columns = nextInt();
    const matrix = new Array(rows);
    for (let i = 0; i < rows; i++) {
        matrix[i] =  nextIntArray(columns)
    }
    let max = 0;
    for (let row = 0; row < rows; row++) {
        for (let col = 0; col < columns; col++) {
            let sum = 0;
            // top left
            for (let rowPlace = row, colPlace = col; rowPlace >= 0 && colPlace >= 0; rowPlace--, colPlace--) {
                sum+= matrix[rowPlace][colPlace];
            }
            // top right
            for (let rowPlace = row, colPlace = col; rowPlace >= 0 && colPlace < columns; rowPlace--, colPlace++) {
                sum+= matrix[rowPlace][colPlace];
            }
            // down left
            for (let rowPlace = row, colPlace = col; rowPlace < rows && colPlace >= 0; rowPlace++, colPlace--) {
                sum+= matrix[rowPlace][colPlace];
            }
            // down right
            for (let rowPlace = row, colPlace = col; rowPlace < rows && colPlace < columns; rowPlace++, colPlace++) {
                sum+= matrix[rowPlace][colPlace];
            }
            sum -= 3* matrix[row][col]

            max = Math.max(max, sum);
        }
    }

    myout(max);
    // for (let i )
}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const [n, m] = lines[l++].trim().split(' ').map(Number)
        const grid = lines.slice(l, l + n).map(str => str.trim().split(' ').map(Number))
        l += n
        output[i] = solve(n, m, grid)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, m, grid) {
    const d1 = {}
    const d2 = {}
    for (let i = 0; i < n; i++) {
        for (let j = 0; j < m; j++) {
            const x = grid[i][j]
            d1[i + j] = (d1[i + j] || 0) + x
            d2[i - j] = (d2[i - j] || 0) + x
        }
    }
    let ans = -Infinity
    for (let i = 0; i < n; i++) {
        for (let j = 0; j < m; j++) {
            ans = Math.max(ans, d1[i + j] + d2[i - j] - grid[i][j])
        }
    }
    return ans
}

'use strict';
// HEADER:
const print = console.log;
let IS_MULTITEST, testN;
const pcalc = testN=>{
  let res = calc(testN);
  if (Array.isArray(res)){
    pa(res);
  } else if (Number.isFinite(res) || typeof res=='string'){
    print(res);
  }
};

const main = ()=>{
  if (IS_MULTITEST){
    let T = +readline()
    for (testN=1; testN<=T; testN++)
      pcalc(T);
  } else
   pcalc();
};

const lines = [];
const rl = require('readline').createInterface({
   input: process.stdin, output: process.stdout});
rl.on('line', line=>{
  lines.push(line);
});
rl.on('close', main);
let rli = 0;
const readline = ()=>lines[rli++];
const L = process.env.DEBUG ? console.log : ()=>{};
const LT = obj=>L(`Test #${testN}`, obj);

const ra = ()=>readline().split(' ').map(a=>+a)
const pa = arr=>print(arr.join(' '));

// SOLUTION:
IS_MULTITEST = 1;

const calc = ()=>{
  // READING:
  let [n, m] = ra();
  let A = [];
  for (let i=0; i<n; i++) A.push(ra())
  LT({n, m, A});
  // PROCESSING:
  let add = (i, j)=>{
    if (i<0 || i>=n)
      return 0;
    if (j<0 || j>=m)
      return 0;
    return A[i][j]
  }
  let ch = (pi, pj)=>{
    let sum = A[pi][pj];
    for (let i=1; i<n; i++){
      sum += add(pi+i, pj+i);
      sum += add(pi+i, pj-i);
      sum += add(pi-i, pj+i);
      sum += add(pi-i, pj-i);
    }
    return sum;
  };
  let ans = 0;
  for (let i=0; i<n; i++){
    for (let j=0; j<m; j++){
      ans = Math.max(ans, ch(i, j))
    }
  }
  return ans;
};

s = parseInt(readline());
for(f = 0; f < s; f++)
{
    var n = readline().split(" ");
    n[0] = parseInt(n[0]);
    n[1] = parseInt(n[1]);
    var strings = [];
    for(i = 0; i < n[0]; i++)
    {
        strings[i] = readline().split(" ");
    }

    var max = 0;
    var sum = 0;
    for(i = 0; i < n[0]; i++)
    {
        for(j = 0; j < n[1]; j++)
        {
            sum = 0;
            sum += parseInt(strings[i][j]);
            var t = 1;
            while(i + t < n[0] && j + t < n[1])
            {
                sum += parseInt(strings[i + t][j + t]);
                t++;
            }
            t = 1;
            while(i + t < n[0] && j - t >= 0)
            {
                sum += parseInt(strings[i + t][j - t]);
                t++;
            }
            t = 1;
            while(i - t >= 0 && j + t < n[1])
            {
                sum += parseInt(strings[i - t][j + t]);
                t++;
            }
            t = 1;
            while(i - t >= 0 && j - t >= 0)
            {
                sum += parseInt(strings[i - t][j - t]);
                t++;
            }
            if(sum > max) max = sum;
        }
    }
    print(max);
}

//import { readline, print } from '@ip-algorithmics/codeforces-io';
var t = +readline();
while (t--) {
    var _a = readline().split(' ').map(function (v) { return +v; }), n = _a[0], m = _a[1];
    var a = Array(n);
    for (var i = 0; i < n; i++) {
        a[i] = readline().split(' ').map(function (v) { return +v; });
    }
    var l = Array(n + m).fill(0, -m, n);
    var r = Array(n + m).fill(0, -m, n);
    for (var i = -m + 1; i < n; i++) {
        l[i] = 0;
        for (var j = Math.max(0, -i); j < Math.min(m, n - i); j++) {
            l[i] += a[i + j][j];
        }
        r[i] = 0;
        for (var j = Math.max(0, -i); j < Math.min(m, n - i); j++) {
            r[i] += a[i + j][m - j - 1];
        }
    }
    var max = 0;
    for (var i = 0; i < n; i++) {
        for (var j = 0; j < m; j++) {
            max = Math.max(max, l[i - j] + r[i - m + j + 1] - a[i][j]);
        }
    }
    print(max);
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = nextLong();
		}else if(code == 'double'){
			ret[i] = nextDouble();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');} function nextDoubleArray(size){return nextArray(size, 'double');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());} function nextDouble(){return parseFloat(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	var d = [[-1,-1],[-1,1],[1,-1],[1,1]];
	while(hasNext()){
		var H = nextInt();
		var W = nextInt();
		var list = new Array(H);
		for(var i = 0; i < H; i++){
			list[i] = nextIntArray(W);
		}
		var output = 0;
		for(var i = 0; i < H; i++){
			for(var j = 0; j < W; j++){
				var sum = list[i][j];
				for(var k = 0; k < d.length; k++){
					var nxY = i + d[k][0];
					var nxX = i + d[k][1];
					while(nxY >= 0 && nxY < H && nxX >= 0 && nxX < W){
						sum += list[nxY][nxX];
						nxY += d[k][0];
						nxX += d[k][1];
					}
				}
				output = Math.max(output, sum);
			}
		}
		myout(output);
	}
}


Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph.There are n toy cars. Each pair collides. The result of a collision can be one of the following: no car turned over, one car turned over, both cars turned over. A car is good if it turned over in no collision. The results of the collisions are determined by an n × n matrix А: there is a number on the intersection of the і-th row and j-th column that describes the result of the collision of the і-th and the j-th car:    - 1: if this pair of cars never collided.  - 1 occurs only on the main diagonal of the matrix.  0: if no car turned over during the collision.  1: if only the i-th car turned over during the collision.  2: if only the j-th car turned over during the collision.  3: if both cars turned over during the collision. Susie wants to find all the good cars. She quickly determined which cars are good. Can you cope with the task?

The first line contains integer n (1 ≤ n ≤ 100) — the number of cars. Each of the next n lines contains n space-separated integers that determine matrix A.  It is guaranteed that on the main diagonal there are  - 1, and  - 1 doesn't appear anywhere else in the matrix. It is guaranteed that the input is correct, that is, if Aij = 1, then Aji = 2, if Aij = 3, then Aji = 3, and if Aij = 0, then Aji = 0.

Print the number of good cars and in the next line print their space-separated indices in the increasing order.

var n = +readline(), input;
var cnt = {}, x;

for(i = 1; i <= n; i++){
	cnt[i] = 0;
}

for(i = 1, x = n-1; i <= n; i++){
	input = readline().split(" ");

	for(j = i; j <= x; j++){
		switch(input[j]){
			case "0":
				break;
			case "1":
				delete cnt[i];
				break;
			case "2":
				delete cnt[j+1];
				break;
			case "3":
				delete cnt[i];
				delete cnt[j+1];
		}
	}
}

print(Object.keys(cnt).length);
if(Object.keys(cnt).length > 0){
	for(key in cnt){
		write(key + " ");
	}
}

function Reader()
{
    this.buffer = [];
    this.cur = 0;
}

Reader.prototype.next = function()
{
    if (this.cur == this.buffer.length)
    {
        this.cur = 0;
        this.buffer = readline().split(' ');
    }
    return this.buffer[this.cur++];
}

function Writer()
{
    this.buffer = "";
}

Writer.prototype.print = function(s)
{
    this.buffer += s;
}

Writer.prototype.println = function(s)
{
    this.buffer += s;
    print(this.buffer);
    this.buffer = "";
}

Writer.prototype.flush = function()
{
    if (this.buffer != "")
    print(this.buffer);
    this.buffer = "";
}

var cin = new Reader();
var cout = new Writer();

var n = +cin.next();

var ans = [];

for(var i = 0; i < n; ++i)
{
    var good = 1;
    var cur;
    for(var j = 0; j < n; ++j)
    {
        cur = +cin.next();
        if (cur == 1 || cur == 3)
            good = 0;
    }
    if (good)
        ans.push(i + 1);
}

cout.println(ans.length);

for(var i = 0; i < ans.length; ++i)
{
    cout.print(ans[i] + " ");
}

cout.flush();

function ProblemSolver() {
    this.HAS_TEST_CASES = false;
    this.INPUT_FILE_NAME = "test.in";
    this.OUTPUT_FILE_NAME = "out.txt";
    this.DO_OUTPUT_TO_FILE = false;
    this.CLEAR_ARRAY_PER_CASE = false;

    this.solveCase = function() {
        var res , i , j , fl , cn , temp ;
        res = [] ;
        for( i = 0 ; i < this.n ; i++ ) {
        	fl = 1 ;
        	for( j = 0 ; j < this.n ; j++ ) {
        		if( i != j && ( this.memo[ i ][ j ] == 1 || this.memo[ i ][ j ] == 3 ) ) {
        			fl = 0 ;
        			break ;
        		}
        	}
        	if( fl == 1 ) {
        		res.push( i + 1 ) ;
        	}
        }
        print( res.length );
        print( res.join( ' ' ) );
    };

    this.init = function() {
        this.lim1 = 100010;
        this.lim2 = 110;
        this.cc = 1;
        this.ind = 1;
        this.n = 0;
        this.cn = 0;
        this.declareAndFillArrays();
    };

    this.getInput = function( irObj ) {
        var hasMoreInput , i;
        hasMoreInput = true;
        try {
            this.n = irObj.nextInt();
            for( i = 0 ; i < this.n ; i++ ) {
            	for( j = 0 ; j < this.n ; j++ ) {
                	this.memo[ i ][ j ] = irObj.nextInt();
               	}
            }
        }
        catch( ex ) {
            hasMoreInput = false;
        }
        return hasMoreInput;
    };

    this.clearArraysPerCase = function() {
        var i;
        this.arr = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.arr.push( 0 );
            this.adj_list.push( new Array() );
        }
    };

    this.clearPerCase = function() {
        this.cn = 0;
        this.cc++;
        if( this.CLEAR_ARRAY_PER_CASE == true ) {
            this.clearArraysPerCase() ;
        }
    };

    this.declareAndFillArrays = function() {
        var i , j;
        this.srr = new Array();
        this.vis = new Array();
        this.arr = new Array();
        this.brr = new Array();
        this.memo = new Array();
        this.done = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.srr.push( "" );
            this.vis.push( 0 );
            this.arr.push( 0 );
            this.brr.push( 0 );
            this.adj_list.push( new Array() );
        }
        for( i = 0 ; i < this.lim2 ; i++ ) {
            this.memo.push( new Array() );
            this.done.push( new Array() );
            for( j = 0 ; j < this.lim2 ; j++ ) {
                this.memo[ i ].push( -1 );
                this.done[ i ].push( 0 );
            }
        }
    };

    this.init();
}

function InputReader() {
    var self = this ;
    this.allLines = new Array();
    this.currrentLineNumber = 0;
    this.currrentCharacterIndex = 0;
    this.callBackFunction = null ;
    this.parentContext = null ;

    this.readAllLines = function() {
        var singleLine;
        while( true ) {
            try {
                singleLine = readline();
                if( singleLine == null ) {
                    break;
                }
            }
            catch( ex ) {
                break;
            }
            this.allLines.push( singleLine );
        }
    };

    this.readAllLinesFromRhino = function() {
        var brObj , line ;
        importPackage( java.io ) ;
        importPackage( java.lang ) ;
        brObj = new BufferedReader( new InputStreamReader( System[ 'in' ] ) ) ;
        this.allLines = [] ;
        while( true ) {
            line = brObj.readLine() ;
            if( line == null ) {
                break;
            }
            this.allLines.push( line ) ;
        }
    };

    this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {
        self.chunkData += chunk ;
    };

    this.readEndFromNodeJsJudgeServer = function() {
        self.parseRawData( self.chunkData ) ;
        self.parentContext.runCases() ;
    };

    this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {
        this.parentContext = parentContext ;
        process.stdin.resume() ;
        process.stdin.setEncoding( 'utf8' ) ;
        this.chunkData = '' ;
        process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;
        process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;
    };

    this.parseRawData = function( data ) {
        var len , i , currentString;
        len = data.length;
        currentString = "";
        this.allLines = [] ;
        for( i = 0 ; i < len ; i++ ) {
            if( data[ i ] == '\r' ) {
            }
            else if( data[ i ] == '\n' ) {
                this.allLines.push( currentString );
                currentString = "";
            }
            else {
                currentString += data[ i ];
            }
        }
        if( currentString != "" ) {
            this.allLines.push( currentString );
        }
    };

    this.readAllLinesFromFile = function( inputFileName ) {
        var currentDirectory , fsObj , inputFilePath , rawData;
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        inputFilePath = currentDirectory + "\\" + inputFileName;
        rawData = fsObj.readFileSync( inputFilePath , "utf8" );
        this.parseRawData( rawData );
    };

    this.next = function( flag ) {
        var len , i , startIdx , res , endIdx;
        if( flag == 0 ) {
            if( this.currrentCharacterIndex != 0 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            res = "";
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;
            }
            this.currrentLineNumber++;
            this.currrentCharacterIndex = 0;
            return res;
        }
        while( true ) {
            if( this.currrentLineNumber >= this.allLines.length ) {
                throw new Error( "No more tokens available!" );
            }
            startIdx = -1;
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) ) {
                    startIdx = i;
                    break;
                }
            }
            if( startIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
                continue;
            }
            res = "";
            endIdx = len - 1 ;
            for( i = startIdx ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) ) {
                    endIdx = i;
                    break;
                }
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) >= 48 && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) <= 57 ) {
                    res += '' + ( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) - 48 ) ;
                }
                else {
                    res += '' + this.allLines[ this.currrentLineNumber ].charAt( i );
                }
            }
            this.currrentCharacterIndex = endIdx;
            if( endIdx == len - 1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            return res;
        }
    };

    this.nextInt = function() {
        return parseInt( this.next( 1 ) );
    };

    this.nextDouble = function() {
        return parseFloat( this.next( 1 ) );
    };

    this.nextString = function() {
        return this.next( 1 );
    };

    this.nextLine = function() {
        return this.next( 0 );
    };
}

function FileOutputHandler() {
    this.resultantStringArray = new Array();

    this.addNewLine = function( newString ) {
        this.resultantStringArray.push( newString );
    };

    this.clearPercase = function() {
        this.resultantStringArray = new Array();
    };

    this.flushOutOutputToFile = function( outputFileName ) {
        var i , sz , res , currentDirectory , fsObj , outputFilePath;
        res = "";
        sz = this.resultantStringArray.length;
        for( i = 0 ; i < sz ; i++ ) {
            if( i != 0 ) {
                res += "\n";
            }
            res += this.resultantStringArray[ i ];
        }
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        outputFilePath = currentDirectory + "\\" + outputFileName;
        fsObj.writeFileSync( outputFilePath , res );
        this.clearPercase();
    };
}

function CodeExecutioner() {
    this.irObj = new InputReader();
    this.psObj = new ProblemSolver();
    this.fohObj = new FileOutputHandler();

    this.runCases = function() {
        if( this.psObj.HAS_TEST_CASES == true ) {
            testCases = this.irObj.nextInt();
            for( i = 0 ; i < testCases ; i++ ) {
                this.psObj.clearPerCase();
                this.psObj.getInput( this.irObj );
                this.psObj.solveCase();
            }
        }
        else {
            while( true ) {
                this.psObj.clearPerCase();
                hasMoreTestCases = this.psObj.getInput( this.irObj );
                if( hasMoreTestCases == false ) {
                    break;
                }
                this.psObj.solveCase();
            }
        }
        if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
            this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );
        }
    };

    this.detectEnvironmentType = function() {
        var environmentType = null ;
        try {
            if( importPackage != null ) {
                environmentType = 'rhino' ;
            }
        }
        catch( ex1 ) {
            try {
                //for nodejs local server check
                if( __dirname != null && readline != null && typeof( readline ) != 'function' ) {
                    environmentType = 'local-node-js' ;
                }
            }
            catch( ex2 ) {
                try {
                    if( readline == null || typeof( readline ) != 'function' ) {
                        environmentType = 'server-node-js' ;
                    }
                    else {
                        try {
                            if( Map != null ) {
                                environmentType = 'spider-monkey' ;
                            }
                            else {
                                environmentType = 'javascript-v8' ;
                            }
                        }
                        catch( ex3 ) {
                            environmentType = 'javascript-v8' ;
                        }
                    }
                }
                catch( ex3 ) {
                    environmentType = 'server-node-js' ;
                }
            }
        }
        return environmentType ;
    };

    this.configureStreamsAndReadInput = function() {
        var testCases , i , hasMoreTestCases , isLocal , localContext , isNodeJsJudgeServer , environmentType ;
        isNodeJsJudgeServer = false ;
        environmentType = this.detectEnvironmentType() ;
        if( environmentType == 'local-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
                localContext = this.fohObj;
                print = function() {
                    localContext.addNewLine.apply( localContext , arguments );
                }
            }
            this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );
            this.runCases() ;
        }
        else if( environmentType == 'server-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;
        }
        else if( environmentType == 'javascript-v8' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
        else if( environmentType == 'rhino' ) {
            this.irObj.readAllLinesFromRhino();
            this.runCases() ;
        }
        else if( environmentType == 'spider-monkey' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
    };

    this.configureStreamsAndReadInput();
}

new CodeExecutioner();

function toi(x){return parseInt(x);}
var n=toi(readline());
var res=[];
var num=0;
for(var i=0;i<n;i++){
    var a=readline().split(" ").map(toi);
    if(a.every(function(x){return x!=1&&x!=3;})){
	res.push((i+1));
	num++;
    }
}
print(num==0?num:""+num+"\n"+res.join(" "));

var n = parseInt( readline() ),
	index = [];
for (var i=0; i<n; i++) {
	readline().split( ' ' ).every( function(el) {
		return el != 1 && el != 3;
	} ) && index.push( i+1 );
}

print( index.length );
index.length && print( index.join( ' ' ) );

// 545A     Игрушечные машинки

var n = parseInt(readline());

// var input_line = readline().split(' ').map(Number);

var arr = [];
var arrTmp = [];

for (var i = 0; i < n; i++) {
    arr[i] = [];
    arr[i] = readline().split(' ').map(Number);
};

Array.prototype.in_array = function(p_val) {
    for(var i = 0, l = this.length; i < l; i++)  {
        if(this[i] == p_val) {
            return true;
        }
    }
    return false;
}

var arrTest = [1, 3];
var flagGood;
var count = n;
var out = '';

for (var i = 0; i < n; i++) {

    flagGood = true;

    for (var j = 0; j < n; j++) {
        if (arrTest.in_array(arr[i][j])) {
            flagGood = false;
        };
    };

    if (!flagGood) {
        count --;
    } else {
        out += (i + 1) + ' ';
    }
};

out = count + '\n' + out + '\n';

print(out);

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;
const ans = [];
let count = 0;

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  if (!/[13]/g.test(d.replace('-1', ''))) {
    count++;
    ans.push(c);
  }

  c++;
});

rl.on('close', () => {
  console.log(count);

  if(ans.length) {
    console.log(ans.join(' '));
  }
});

process.stdin.setEncoding('ASCII');

let string = '';
process.stdin.on( 'data', (data) => string += data );

process.stdin.on('end', () => {
    const array = string.split("\n");
    let n = Number(array[0]);

    let flipped = Array(110).fill(0);

    for (let i = 1; i <= n; ++i) {
        const row = array[i].split(" ").map(Number);

        for (let j = 0; j < n; ++j) {
            if (row[j] == 0 || row[j] == -1) continue;
            if (row[j] == 1)  flipped[i]++;
            else if (row[j] == 2) flipped[j + 1]++;
            else if (row[j] == 3) flipped[i]++, flipped[j + 1 ]++;
        }
    }

    let cnt = 0, result = '';
    for (let i = 1; i <= n; ++i) if (flipped[i] == 0) cnt++, result += i + ' ';
    console.log(cnt);
    console.log(result);
});

var n = parseInt( readline() ),
	index = [];
for (var i=0; i<n; i++) {
	readline().split( ' ' ).every( function(el) {
		return el != 1 && el != 3;
	} ) && index.push( i );
}

print( index.length );
print( index.join( ' ' ) );