import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main ()
{
	auto tests = readln.strip.to !(int);
	foreach (test; 0..tests)
	{
		auto n = readln.strip.to !(int);
		int [] [] board;
		foreach (row; 0..n * 2)
		{
			board ~= readln.splitter.map !(to !(int)).array;
		}
		auto res = 0L;
		foreach (row; n..n * 2)
		{
			foreach (col; n..n * 2)
			{
				res += board[row][col];
			}
		}
		res += min (board[n][0], board[$ - 1][0],
		    board[n][n - 1], board[$ - 1][n - 1],
		    board[0][n], board[n - 1][n],
		    board[0][$ - 1], board[n - 1][$ - 1]);
		writeln (res);
	}
}
