A permutation of length $$$n$$$ is a sequence of integers from $$$1$$$ to $$$n$$$ of length $$$n$$$ containing each number exactly once. For example, $$$[1]$$$, $$$[4, 3, 5, 1, 2]$$$, $$$[3, 2, 1]$$$ are permutations, and $$$[1, 1]$$$, $$$[0, 1]$$$, $$$[2, 2, 1, 4]$$$ are not.There was a permutation $$$p[1 \dots n]$$$. It was merged with itself. In other words, let's take two instances of $$$p$$$ and insert elements of the second $$$p$$$ into the first maintaining relative order of elements. The result is a sequence of the length $$$2n$$$.For example, if $$$p=[3, 1, 2]$$$ some possible results are: $$$[3, 1, 2, 3, 1, 2]$$$, $$$[3, 3, 1, 1, 2, 2]$$$, $$$[3, 1, 3, 1, 2, 2]$$$. The following sequences are not possible results of a merging: $$$[1, 3, 2, 1, 2, 3$$$], [$$$3, 1, 2, 3, 2, 1]$$$, $$$[3, 3, 1, 2, 2, 1]$$$.For example, if $$$p=[2, 1]$$$ the possible results are: $$$[2, 2, 1, 1]$$$, $$$[2, 1, 2, 1]$$$. The following sequences are not possible results of a merging: $$$[1, 1, 2, 2$$$], [$$$2, 1, 1, 2]$$$, $$$[1, 2, 2, 1]$$$.Your task is to restore the permutation $$$p$$$ by the given resulting sequence $$$a$$$. It is guaranteed that the answer exists and is unique.You have to answer $$$t$$$ independent test cases.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 400$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of permutation. The second line of the test case contains $$$2n$$$ integers $$$a_1, a_2, \dots, a_{2n}$$$ ($$$1 \le a_i \le n$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. It is guaranteed that the array $$$a$$$ represents the result of merging of some permutation $$$p$$$ with the same permutation $$$p$$$.

For each test case, print the answer: $$$n$$$ integers $$$p_1, p_2, \dots, p_n$$$ ($$$1 \le p_i \le n$$$), representing the initial permutation. It is guaranteed that the answer exists and is unique.

function solve() {
   var n = Number(read());
   var arr = readArray(Number);
   var ans = [];
   var s = {};
   for (var i = 0; i < (n << 1); i++) {
      if (s[arr[i]]) {
         ans.push(arr[i]);
      } else {
         s[arr[i]] = true;
      }
   }
   write(ans.join(' '));
}

function init() {
   var T;
   T = 1;
   T = Number(read());
   for (var t = 0; t < T; t++) {
      solve();
   }
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function readArray(f) {
   return read().split(' ').map(f);
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;

   var needWriteFile = false;

   var writeResult = '';
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      var RL = require('readline').createInterface({
         input : process.stdin,
         output : process.stdout
      });

      RL.on('line', (line) => {
         MEMORY.push(line);
      });

      RL.on('close', init);
   }
} else {
   init();
}

function write(value) {
   if (needWriteFile) {
      writeResult += value + '\n';
      return;
   }
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}

const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

rl.question("", function (n) {
  functions();
})

function functions() {
  rl.question("", function (n) {
    rl.question("", function (num) {
      var arr = num.split(' ');
      var l = [];
      for (var i = 0; i < n * 2; i++) {
        for (var j = 0; j < arr.length; j++) {
          var lhas = l.includes(arr[j])
          if (!lhas) {
            l.push(arr[j]);

          }
        }
      }
      console.log(l.join(' '));
      functions();
    });
  })
}
// rl.question('', function (o) {
//   rl.question('', function (n) {
//     rl.question('', function (a) {
//       rl.question('', function (b) {
//         var s = 0;
//         var sa = a.split(' ');
//         var sb = b.split(' ');
//         // console.log(n, newA, s, sa, sb)
//         for (var i = 0; i < n; i++) {
//           var newA = [];
//           var ai = sa[i] - Math.min.apply(Math, sa)
//           var bi = sb[i] - Math.min.apply(Math, sb)
//           newA.push(ai);
//           newA.push(bi);
//           s += Math.max.apply(Math, newA);
//         }
//         console.log(s)
//         functions();
//       })
//     })
//   })
// })

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  let t = +readLine();
  while (t--) {
    const len = +readLine();
    let arr = readLine()
      .split(" ")
      .map((n) => parseInt(n));
    const result = [];
    const map = arr.reduce((obj, num) => {
      if (!obj[num]) {
        obj[num] = 1;
        result.push(num);
      }
      return obj;
    }, {});
    console.log(result.join(" "));
  }
}

//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;

  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
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(){
	var t = nextInt();
	var output = [];
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var list = nextIntArray();
		var out = [];
		for(var j = 0; j < list.length; j++){
			if(out.indexOf(list[j]) == -1){
				out.push(list[j]);
			}
		}
		output[i] = myconv(out,8);
	}
	myout(myconv(output,9));
}

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

let stdinInput = '';

process.stdin.on('data', input => {
  stdinInput += input;
});

process.stdin.on('end', () => {
  main(stdinInput);
});

function main(data) {
	data = data.split('\n');
	const testCases = data[0] * 2;
	let i = 1;
	while (i <= testCases) {
    let n = data[i] * 1;
    let a = data[i + 1].trim().split(' ');
    let str = a[0]
    let obj = {};
    obj[str] = true;
    for (let i = 1; i < a.length; i += 1) {
      if (obj[a[i]]) {}
      else {
        obj[a[i]] = true;
        str += ' ' + a[i];
      }
    }
    console.log(str);
    i += 2;
	}
}

const processData = (lines) => {
  let num = 0;
  const n = +lines[num++];
  for (let i = 0; i < n; i++) {
    num++;
    const line = lines[num++].split(" ").map((x) => +x); //转数字
    const map = new Map();
    const res = [];
    line.forEach((element) => {
      if (map.get(element) === undefined) {
        map.set(element, 1);
        res.push(element);
      }
    });
    console.log(res.join(" "));
  }
};

let i = "";
process.stdin.on("data", (c) => (i += c));
process.stdin.on("end", () => {
  const { EOL } = require("os"); //获取换行符
  const lines = i.split(EOL);
  processData(lines);
});

'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 readline() {
    return inputString[currentLine++];
}

function main() {
	const testcases = parseInt(readline());
	for (let i = 0; i < testcases; i++) {
		const l = parseInt(readline());
		const merged = readline().split(' ').map(i => parseInt(i))
		const unique = Array.from(new Set([...merged]))
		console.log(unique.join(' '))
	}
}

const processData = (lines) => {
    let acc = 0
    const n = +lines[acc++]
    for (let i=0; i<n; i++) {
        acc++
        const p = lines[acc++].split(' ').map(x => +x)

        const map = {}
        const res = []
        for (const t of p) {
            if (!map[t]) {
                map[t] = 1
                res.push(t)
            }
        }
        console.log(res.join(' '))
    }

}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    processData(lines)
})

"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ************************ Code Start ***************************

function main() {

  var tc = parseInt(readline());
  while (tc--) {
    var n = parseInt(readline());
    var ar = readline().split(' ').map(x => parseInt(x));
    var unique = Array.from(new Set([...ar]));
    print(unique.join(' '));
  }

}

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

let currentLine = 0;
let inputString = "";

process.stdin.on("data", (raw_data) => {
  inputString += raw_data;
});

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

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

/******** Main function*************/

function main() {
  var t = +readLine();

  for (var i = 0; i < t; i++) {
    var n = +readLine();
    var arr = readLine().split(" ").map(Number);
    const uni = [...new Set(arr)];
    console.log(uni.join(" "));
  }
}

'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 readline() {
    return inputString[currentLine++];
}
/**
5
2
1 1 2 2
4
1 3 1 4 3 4 2 2
5
1 2 1 2 3 4 3 5 4 5
3
1 2 3 1 2 3
4
2 3 2 4 1 3 4 1

**/

function gcd(a, b) {
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
};

function lcm(a, b) {
    return (a / gcd(a, b) * b);
}

function main() {
    let n = Number(readline());

    for(let r=0;r<n;r++) {
        solve(r);
    }

}

function solve(index) {
    let n = Number(readline())
    let a = readline().split(" ").map(Number);

    let output = new Set([...a]);

    console.log([...output].join(" "));

}

const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

var lineCount = 0
var testCount = 0
var outputStr = ''

rl.on('line', (input) => {
    if (lineCount == 0) {
        // first line
        testCount = parseInt(input)
    }
    else if(lineCount%2==1){
        //do nothing?
    }
    else if (lineCount >= 2*testCount) {
        outputStr += compute(input) + '\n'
        console.log(outputStr)
        rl.close()
    }
    else {
        // data
        outputStr += compute(input) + '\n'
    }
    lineCount++
});

function compute(str) {
    var list = str.split(' ')

    var tmplist = []

    var resultstr = ''

    for(var item of list){
        if(tmplist[item]){
            // already exist
            continue
        }
        resultstr += `${item} `
        tmplist[item] = true
    }
    return resultstr
}

const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

rl.question("", function (n) {
  functions();
})

function functions() {
  rl.question("", function (n) {
    rl.question("", function (num) {
      var arr = num.split(' ');
      var l = [];
      for (var i = 0; i < n * 2; i++) {
        for (var j = 0; j < arr.length; j++) {
          var lhas = l.includes(arr[j])
          if (!lhas) {
            l.push(arr[j]);
          }
        }
      }
      console.log(l);
      functions();
    });
  })
}
// rl.question('', function (o) {
//   rl.question('', function (n) {
//     rl.question('', function (a) {
//       rl.question('', function (b) {
//         var s = 0;
//         var sa = a.split(' ');
//         var sb = b.split(' ');
//         // console.log(n, newA, s, sa, sb)
//         for (var i = 0; i < n; i++) {
//           var newA = [];
//           var ai = sa[i] - Math.min.apply(Math, sa)
//           var bi = sb[i] - Math.min.apply(Math, sb)
//           newA.push(ai);
//           newA.push(bi);
//           s += Math.max.apply(Math, newA);
//         }
//         console.log(s)
//         functions();
//       })
//     })
//   })
// })


Do you know a story about the three musketeers? Anyway, you will learn about its origins now.Richelimakieu is a cardinal in the city of Bearis. He is tired of dealing with crime by himself. He needs three brave warriors to help him to fight against bad guys.There are n warriors. Richelimakieu wants to choose three of them to become musketeers but it's not that easy. The most important condition is that musketeers must know each other to cooperate efficiently. And they shouldn't be too well known because they could be betrayed by old friends. For each musketeer his recognition is the number of warriors he knows, excluding other two musketeers.Help Richelimakieu! Find if it is possible to choose three musketeers knowing each other, and what is minimum possible sum of their recognitions.

The first line contains two space-separated integers, n and m (3 ≤ n ≤ 4000, 0 ≤ m ≤ 4000) — respectively number of warriors and number of pairs of warriors knowing each other. i-th of the following m lines contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi). Warriors ai and bi know each other. Each pair of warriors will be listed at most once.

If Richelimakieu can choose three musketeers, print the minimum possible sum of their recognitions. Otherwise, print "-1" (without the quotes).

NoteIn the first sample Richelimakieu should choose a triple 1, 2, 3. The first musketeer doesn't know anyone except other two musketeers so his recognition is 0. The second musketeer has recognition 1 because he knows warrior number 4. The third musketeer also has recognition 1 because he knows warrior 4. Sum of recognitions is 0 + 1 + 1 = 2.The other possible triple is 2, 3, 4 but it has greater sum of recognitions, equal to 1 + 1 + 1 = 3.In the second sample there is no triple of warriors knowing each other.

var input = readline().split(' ');
var n = parseInt(input[0], 10);
var m = parseInt(input[1], 10);

warriors = [];
deg = [];

for(var i = 0; i < n; i++) {
    var fill = [];
    for(var j = 0; j < n; j++) {
        fill.push(false);
    }
    warriors.push(fill);
    deg.push(0);
}

for(var i = 0; i < m; i++) {
    input = readline().split(' ');
    var a = parseInt(input[0], 10);
    var b = parseInt(input[1], 10);
    warriors[a - 1][b - 1] = true;
    warriors[b - 1][a - 1] = true;
    deg[a - 1] += 1;
    deg[b - 1] += 1;
}

var result = 100000000000;

for(var i = 0; i < n; i++) {
    for(var j = i + 1; j < n; j++) {
        if (warriors[i][j]) {
            for(var k = j + 1; k < n; k++) {
                if (warriors[i][k] && warriors[j][k]) {
                    var sum = deg[i] + deg[j] + deg[k];
                    result = Math.min(result, sum);
                }
            }
        }
    }
}

result === 100000000000 ? print('-1') : print(result - 6);

/// <reference path="typings/lodash/lodash.d.ts" />
/// <reference path="typings/d8/d8.d.ts" />
function ints() {
    var s = readline();
    return s.split(' ').map(function (x) { return parseInt(x); });
}
function array(length, value) {
    var result = new Array(length);
    for (var i = 0; i < length; i++) {
        result[i] = value();
    }
    return result;
}
var _a = ints(), n = _a[0], m = _a[1];
var adj = array(n + 1, function () { return array(n + 1, function () { return false; }); });
var edges = [];
var degree = array(n + 1, function () { return 0; });
for (var i = 0; i < m; i++) {
    var _b = ints(), a = _b[0], b = _b[1];
    adj[a][b] = true;
    adj[b][a] = true;
    ++degree[a];
    ++degree[b];
    edges.push({ first: a, second: b });
}
var best = 6000;
for (var _i = 0; _i < edges.length; _i++) {
    var x = edges[_i];
    var first = x.first, second = x.second;
    for (var i = 1; i <= n; i++) {
        if (first != i && second != i && adj[first][i] && adj[second][i]) {
            var current = degree[first] + degree[second] + degree[i];
            if (best > current)
                best = current;
        }
    }
}
if (best == 6000)
    best = -1;
else
    best -= 6;
print(best);

/* TEST CASE
input
5 6
1 2
1 3
2 3
2 4
3 4
4 5
output
2

input
7 4
2 1
3 6
5 1
1 7
output
-1

*/
function minimumSumOfRecogitions(nodes, adjMap) {
	var ret = Infinity;
	var n = nodes.length;
	var i, j, k;
//	var sorter = function (v1, v2) {return v1.neighbors.length - v2.neighbors.length;};
//	for (i = 0; i < n; i++) {
//		nodes[i].neighbors.sort(sorter);
//	}
//	nodes.sort(sorter);

	for (i = 0; i < n; i++) {
		var node1 = nodes[i];
		if (node1.neighbors.length - 2 < ret) {
			for (j = 0; j < node1.neighbors.length; j++) {
				var node2 = node1.neighbors[j];

				if (node1.neighbors.length + node2.neighbors.length - 4 < ret) {
					for (k = 0; k < node2.neighbors.length; k++) {
						var node3 = node2.neighbors[k];
						if (node3.adjMap[node1.nodeIndex] != null)
							ret = Math.min(ret, node1.neighbors.length + node2.neighbors.length + node3.neighbors.length - 6);
					}
				}
			}
		}
	}

	return ret == Infinity ? -1 : ret;
}

function main() {
	var splitted = readline().split(' ');
	var n = parseInt(splitted[0]);
	var m = parseInt(splitted[1]);
	var nodes = new Array(n);
	var i;
	var u, v;
	var dummyObj = {};
	var adjMap = {};

	for (u = 0; u < n; u++) {
		nodes[u] = {nodeIndex: u, neighbors: [], adjMap: {}};
	}
	for (i = 0; i < m; i++) {
		splitted = readline().split(' ');
		u = parseInt(splitted[0]) - 1;
		v = parseInt(splitted[1]) - 1;
		if (u != v) {
			nodes[u].adjMap[v] = dummyObj;
			nodes[v].adjMap[u] = dummyObj;
			nodes[u].neighbors.push(nodes[v]);
			nodes[v].neighbors.push(nodes[u]);
		}
	}

	var answer = minimumSumOfRecogitions(nodes, adjMap);
	print(answer);
}

main();

/* TEST CASE
input
5 6
1 2
1 3
2 3
2 4
3 4
4 5
output
2

input
7 4
2 1
3 6
5 1
1 7
output
-1

*/
function minimumSumOfRecogitions(nodes) {
	var ret = Infinity;
	var n = nodes.length;
	var i, j, k;
	var sorter = function (v1, v2) {return v1.neighbors.length - v2.neighbors.length;};
	for (i = 0; i < n; i++) {
		nodes[i].neighbors.sort(sorter);
	}
	nodes.sort(sorter);

	for (i = 0; i < n; i++) {
		var node1 = nodes[i];
		if (node1.neighbors.length - 2 >= ret) {
			break;
		}
		for (j = 0; j < node1.neighbors.length; j++) {
			var node2 = node1.neighbors[j];

			if (node1.neighbors.length + node2.neighbors.length - 4 >= ret) {
				break;
			}
			for (k = 0; k < node2.neighbors.length; k++) {
				var node3 = node2.neighbors[k];
				if (node3.adjMap[node1.nodeIndex] != null)
					ret = Math.min(ret, node1.neighbors.length + node2.neighbors.length + node3.neighbors.length - 6);
			}
		}
	}

	return ret == Infinity ? -1 : ret;
}

function main() {
	var splitted = readline().split(' ');
	var n = parseInt(splitted[0]);
	var m = parseInt(splitted[1]);
	var nodes = new Array(n);
	var i;
	var u, v;
	var dummyObj = {};

	for (u = 0; u < n; u++) {
		nodes[u] = {nodeIndex: u, neighbors: [], adjMap: {}};
	}
	for (i = 0; i < m; i++) {
		splitted = readline().split(' ');
		u = parseInt(splitted[0]) - 1;
		v = parseInt(splitted[1]) - 1;
		if (u != v) {
			nodes[u].adjMap[v] = dummyObj;
			nodes[v].adjMap[u] = dummyObj;
			nodes[u].neighbors.push(nodes[v]);
			nodes[v].neighbors.push(nodes[u]);
		}
	}

	var answer = minimumSumOfRecogitions(nodes);
	print(answer);
}

main();

/* TEST CASE
input
5 6
1 2
1 3
2 3
2 4
3 4
4 5
output
2

input
7 4
2 1
3 6
5 1
1 7
output
-1

*/
function minimumSumOfRecogitions(nodes) {
	var ret = Infinity;
	var n = nodes.length;
	var i, j, k;
	var sorter = function (v1, v2) {return v1.neighbors.length - v2.neighbors.length;};
//	for (i = 0; i < n; i++) {
//		nodes[i].neighbors.sort(sorter);
//	}
	nodes.sort(sorter);

	for (i = 0; i < n; i++) {
		var node1 = nodes[i];
		if (node1.neighbors.length - 2 >= ret) {
			break;
		}
		for (j = 0; j < node1.neighbors.length; j++) {
			var node2 = node1.neighbors[j];

			if (node1.neighbors.length + node2.neighbors.length - 4 < ret) {
				for (k = 0; k < node2.neighbors.length; k++) {
					var node3 = node2.neighbors[k];
					if (node3.adjMap[node1.nodeIndex] != null)
						ret = Math.min(ret, node1.neighbors.length + node2.neighbors.length + node3.neighbors.length - 6);
				}
			}
		}
	}

	return ret == Infinity ? -1 : ret;
}

function main() {
	var splitted = readline().split(' ');
	var n = parseInt(splitted[0]);
	var m = parseInt(splitted[1]);
	var nodes = new Array(n);
	var i;
	var u, v;
	var dummyObj = {};

	for (u = 0; u < n; u++) {
		nodes[u] = {nodeIndex: u, neighbors: [], adjMap: {}};
	}
	for (i = 0; i < m; i++) {
		splitted = readline().split(' ');
		u = parseInt(splitted[0]) - 1;
		v = parseInt(splitted[1]) - 1;
		if (u != v) {
			nodes[u].adjMap[v] = dummyObj;
			nodes[v].adjMap[u] = dummyObj;
			nodes[u].neighbors.push(nodes[v]);
			nodes[v].neighbors.push(nodes[u]);
		}
	}

	var answer = minimumSumOfRecogitions(nodes);
	print(answer);
}

main();

/* TEST CASE
input
5 6
1 2
1 3
2 3
2 4
3 4
4 5
output
2

input
7 4
2 1
3 6
5 1
1 7
output
-1

*/
function minimumSumOfRecogitions(nodes) {
	var ret = Infinity;
	var n = nodes.length;
	var i, j, k;

	for (i = 0; i < n; i++) {
		var node1 = nodes[i];
		var n1 = node1.neighbors.length;
		if (n1 - 2 < ret) {
			for (j = 0; j < n1; j++) {
				var node2 = node1.neighbors[j];
				var n2 = node2.neighbors.length;

				if (n1 + n2 - 4 < ret) {
					for (k = 0; k < node2.neighbors.length; k++) {
						var node3 = node2.neighbors[k];
						if (node3.adjMap[node1.nodeIndex] != null) {
							ret = Math.min(ret, n1 + n2 + node3.neighbors.length - 6);
						}
					}
				}
			}
		}
	}

	return ret == Infinity ? -1 : ret;
}

function main() {
	var splitted = readline().split(' ');
	var n = parseInt(splitted[0]);
	var m = parseInt(splitted[1]);
	var nodes = new Array(n);
	var i;
	var u, v;
	var dummyObj = {};

	for (u = 0; u < n; u++) {
		nodes[u] = {nodeIndex: u, neighbors: [], adjMap: {}};
	}
	for (i = 0; i < m; i++) {
		splitted = readline().split(' ');
		u = parseInt(splitted[0]) - 1;
		v = parseInt(splitted[1]) - 1;
		if (u != v) {
			nodes[u].adjMap[v] = dummyObj;
			nodes[v].adjMap[u] = dummyObj;
			nodes[u].neighbors.push(nodes[v]);
			nodes[v].neighbors.push(nodes[u]);
		}
	}

	var answer = minimumSumOfRecogitions(nodes);
	print(answer);
}

main();

/* TEST CASE
input
5 6
1 2
1 3
2 3
2 4
3 4
4 5
output
2

input
7 4
2 1
3 6
5 1
1 7
output
-1

*/
function minimumSumOfRecogitions(nodes) {
	var ret = Infinity;
	var n = nodes.length;
	var i, j, k;

	for (i = 0; i < n; i++) {
		var node1 = nodes[i];
		var n1 = node1.neighbors.length;
		if (n1 - 2 < ret) {
			for (j = 0; j < n1; j++) {
				var node2 = node1.neighbors[j];
				var n2 = node2.neighbors.length;

				if (n1 + n2 - 4 < ret) {
					for (k = 0; k < n2; k++) {
						var node3 = node2.neighbors[k];
						if (node3.adjMap[node1.nodeIndex] != null) {
							ret = Math.min(ret, n1 + n2 + node3.neighbors.length - 6);
						}
					}
				}
			}
		}
	}

	return ret < Infinity ? ret : -1;
}

function main() {
	var splitted = readline().split(' ');
	var n = parseInt(splitted[0]);
	var m = parseInt(splitted[1]);
	var nodes = new Array(n);
	var i;
	var u, v;
	var dummyObj = {};

	for (u = 0; u < n; u++) {
		nodes[u] = {nodeIndex: u, neighbors: [], adjMap: {}};
	}
	for (i = 0; i < m; i++) {
		splitted = readline().split(' ');
		u = parseInt(splitted[0]) - 1;
		v = parseInt(splitted[1]) - 1;
		if (u != v) {
			nodes[u].adjMap[v] = dummyObj;
			nodes[v].adjMap[u] = dummyObj;
			nodes[u].neighbors.push(nodes[v]);
			nodes[v].neighbors.push(nodes[u]);
		}
	}

	var answer = minimumSumOfRecogitions(nodes);
	print(answer);
}

main();

/* TEST CASE
input
5 6
1 2
1 3
2 3
2 4
3 4
4 5
output
2

input
7 4
2 1
3 6
5 1
1 7
output
-1

*/
function minimumSumOfRecogitions(nodes) {
	var ret = Infinity;
	var n = nodes.length;
	var i, j, k;

	for (i = 0; i < n; i++) {
		var node1 = nodes[i];
		if (node1.neighbors.length - 2 < ret) {
			for (j = 0; j < node1.neighbors.length; j++) {
				var node2 = node1.neighbors[j];

				if (node1.neighbors.length + node2.neighbors.length - 4 < ret) {
					for (k = 0; k < node2.neighbors.length; k++) {
						var node3 = node2.neighbors[k];
						if (node3.adjMap[node1.nodeIndex] != null) {
							var newRecognitions = node1.neighbors.length + node2.neighbors.length + node3.neighbors.length - 6;
							if (ret > newRecognitions) {
								ret = newRecognitions;
							}
						}
					}
				}
			}
		}
	}

	return ret == Infinity ? -1 : ret;
}

function main() {
	var splitted = readline().split(' ');
	var n = parseInt(splitted[0]);
	var m = parseInt(splitted[1]);
	var nodes = new Array(n);
	var i;
	var u, v;
	var dummyObj = {};

	for (u = 0; u < n; u++) {
		nodes[u] = {nodeIndex: u, neighbors: [], adjMap: {}};
	}
	for (i = 0; i < m; i++) {
		splitted = readline().split(' ');
		u = parseInt(splitted[0]) - 1;
		v = parseInt(splitted[1]) - 1;
		if (u != v) {
			nodes[u].adjMap[v] = dummyObj;
			nodes[v].adjMap[u] = dummyObj;
			nodes[u].neighbors.push(nodes[v]);
			nodes[v].neighbors.push(nodes[u]);
		}
	}

	var answer = minimumSumOfRecogitions(nodes);
	print(answer);
}

main();

/* TEST CASE
input
5 6
1 2
1 3
2 3
2 4
3 4
4 5
output
2

input
7 4
2 1
3 6
5 1
1 7
output
-1

*/
function minimumSumOfRecogitions(nodes, adjMap) {
	var ret = Infinity;
	var n = nodes.length;
	var i, j, k;
//	var sorter = function (v1, v2) {return v1.neighbors.length - v2.neighbors.length;};
//	for (i = 0; i < n; i++) {
//		nodes[i].neighbors.sort(sorter);
//	}
//	nodes.sort(sorter);

	for (i = 0; i < n; i++) {
		var node1 = nodes[i];
		if (node1.neighbors.length < ret) {
			for (j = 0; j < node1.neighbors.length; j++) {
				var node2 = node1.neighbors[j];

				if (node1.neighbors.length + node2.neighbors.length < ret) {
					for (k = 0; k < node2.neighbors.length; k++) {
						var node3 = node2.neighbors[k];
						if (node3.adjMap[node1.nodeIndex] != null)
							ret = Math.min(ret, node1.neighbors.length + node2.neighbors.length + node3.neighbors.length - 6);
					}
				}
			}
		}
	}

	return ret == Infinity ? -1 : ret;
}

function main() {
	var splitted = readline().split(' ');
	var n = parseInt(splitted[0]);
	var m = parseInt(splitted[1]);
	var nodes = new Array(n);
	var i;
	var u, v;
	var dummyObj = {};
	var adjMap = {};

	for (u = 0; u < n; u++) {
		nodes[u] = {nodeIndex: u, neighbors: [], adjMap: {}};
	}
	for (i = 0; i < m; i++) {
		splitted = readline().split(' ');
		u = parseInt(splitted[0]) - 1;
		v = parseInt(splitted[1]) - 1;
		if (u != v) {
			nodes[u].neighbors.push(nodes[v]);
			nodes[u].adjMap[v] = dummyObj;
			nodes[v].neighbors.push(nodes[u]);
			nodes[v].adjMap[u] = dummyObj;
		}
	}

	var answer = minimumSumOfRecogitions(nodes, adjMap);
	print(answer);
}

main();

/* TEST CASE
input
5 6
1 2
1 3
2 3
2 4
3 4
4 5
output
2

input
7 4
2 1
3 6
5 1
1 7
output
-1

*/
function minimumSumOfRecogitions(nodes, adjMap) {
	var n = nodes.length;
	var i, j, k;
	var sorter = function (v1, v2) {return v1.neighbors.length - v2.neighbors.length;};
	for (i = 0; i < n; i++) {
		nodes[i].neighbors.sort(sorter);
	}
	nodes.sort(sorter);

	for (i = 0; i < n; i++) {
		var node1 = nodes[i];
		for (j = 0; j < node1.neighbors.length; j++) {
			var node2 = node1.neighbors[j];

			for (k = 0; k < node2.neighbors.length; k++) {
				var node3 = node2.neighbors[k];
				if (adjMap[Math.min(node3.nodeIndex, node1.nodeIndex) + ":" + Math.max(node3.nodeIndex, node1.nodeIndex)] != null)
					return node1.neighbors.length + node2.neighbors.length + node3.neighbors.length - 6;
			}
		}
	}

	return -1;
}

function main() {
	var splitted = readline().split(' ');
	var n = parseInt(splitted[0]);
	var m = parseInt(splitted[1]);
	var nodes = new Array(n);
	var i;
	var u, v;
	var dummyObj = {};
	var adjMap = {};

	for (u = 0; u < n; u++) {
		nodes[u] = {nodeIndex: u, neighbors: []};
	}
	for (i = 0; i < m; i++) {
		splitted = readline().split(' ');
		u = parseInt(splitted[0]) - 1;
		v = parseInt(splitted[1]) - 1;
		if (u != v) {
			nodes[u].neighbors.push(nodes[v]);
			nodes[v].neighbors.push(nodes[u]);
			adjMap[Math.min(u, v) + ":" + Math.max(u, v)] = dummyObj;
		}
	}

	var answer = minimumSumOfRecogitions(nodes, adjMap);
	print(answer);
}

main();


Anfisa the monkey learns to type. She is yet unfamiliar with the "space" key and can only type in lower-case Latin letters. Having typed for a fairly long line, Anfisa understood that it would be great to divide what she has written into k lines not shorter than a and not longer than b, for the text to resemble human speech more. Help Anfisa.

The first line contains three integers k, a and b (1 ≤ k ≤ 200, 1 ≤ a ≤ b ≤ 200). The second line contains a sequence of lowercase Latin letters — the text typed by Anfisa. It is guaranteed that the given line is not empty and its length does not exceed 200 symbols.

Print k lines, each of which contains no less than a and no more than b symbols — Anfisa's text divided into lines. It is not allowed to perform any changes in the text, such as: deleting or adding symbols, changing their order, etc. If the solution is not unique, print any of them. If there is no solution, print "No solution" (without quotes).

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

var isValid = function(s,pieces,len,minLen,maxLen){
    let sLen = s.length;
    let temp = sLen-len*(pieces-1);
    return temp>=minLen && temp<=maxLen;
}
var indicator=0,minLen,maxLen,pieces,temp=[];

rl.on('line', (input) => {
    if(indicator==0){
        temp = input.split(' ').map(item => parseInt(item));
        pieces = temp[0];
        minLen = temp[1];
        maxLen = temp[2];
        indicator++;
    }
    else{
        let i=minLen;
        for( ;i<=maxLen;i++)
            if(isValid(input,pieces,i,minLen,maxLen)) break;

        if(i==maxLen+1) console.log("No solution");
        else{
            /**
             * 0123456789..
             * abrakadabra
             */
            let startIndex=0;
            for(let j=0;j<pieces-1;j++){
            console.log(input.substr(startIndex,i));
            startIndex+=i;
            }
            console.log(input.substr(startIndex));
        }
        rl.close();
    }
  });

'use strict'

const getLine = () => readline().split(' ')
const getInts = () => getLine().map(n => parseInt(n))
const getInt = () => getInts()[0]
const D = (...args) => { // D({name})
  [...args].forEach(cur => print.apply(print, [JSON.stringify(cur)]))
}

main()

function main() {
  const inp = getInts()
  let s = getLine()[0]
  solve(s, ...inp)
}

function solve (s, k, a, b) {
  let n = s.length
  const dp = []
  for (let i = 0; i <= k; ++i) {
    dp.push([])
  }

  for (let i = 0; i <= k; ++i) {
    for (let j = 0; j <= n; ++j) {
      dp[i][j] = 0
    }
  }

  for (let i = a; i <= b; ++i) dp[1][i] = 1

  for (let i = 2; i <= k; ++i) {
    for (let j = i * a; j <= i * b && j <= n; ++j) {
      dp[i][j] = 1
    }
  }

  if (dp[k][n] === 0) print('No solution')
  else {
    const path = []
    for (let i = k; i > 1; --i) {
      for (let j = a; j <= b; ++j) {
        const val = n - j
        if (dp[i - 1][val]) {
          path.push(j)
          n -= j
          break
        }
      }
    }

    path.push(n)
    let ind = 0
    for (let i in path) {
      print(s.slice(ind, ind + path[i]))
      ind += path[i]
    }
  }
}

'use strict'

const getLine = () => readline().split(' ')
const getInts = () => getLine().map(n => parseInt(n))
const getInt = () => getInts()[0]
const D = (...args) => { // D({name})
  [...args].forEach(cur => print.apply(print, [JSON.stringify(cur)]))
}
const dp = {}

main()

function main() {
  const inp = getInts()
  let s = getLine()[0]
  const n = s.length

  const possible = solve(n, ...inp)
  if (!possible) print('No solution')
  else {
    let curN = n
    let curK = inp[0]
    let a = inp[1]
    const b = inp[2]
    while (a <= b) {
      const ok = solve(curN - a, curK - 1, a, b)
      if (ok) {
        print(s.slice(0, a))
        s = s.slice(a)
        curN -= a
        curK --
      }
      a ++
    }
  }
}

function solve (n, k, a, b) {
  if (n <= 0) {
    return n === 0 && k === 0
  }

  if (Object.hasOwnProperty(dp, [n, k])) return dp[[n, k]]

  let ans = 0
  for (let i = a; i <= b; ++i) {
    ans += solve(n - i, k - 1, a, b)
  }

  return dp[[n, k]] = ans
}


You are given an integer $$$n$$$ and an array $$$a_1, a_2, \ldots, a_n$$$. You should reorder the elements of the array $$$a$$$ in such way that the sum of $$$\textbf{MEX}$$$ on prefixes ($$$i$$$-th prefix is $$$a_1, a_2, \ldots, a_i$$$) is maximized.Formally, you should find an array $$$b_1, b_2, \ldots, b_n$$$, such that the sets of elements of arrays $$$a$$$ and $$$b$$$ are equal (it is equivalent to array $$$b$$$ can be found as an array $$$a$$$ with some reordering of its elements) and $$$\sum\limits_{i=1}^{n} \textbf{MEX}(b_1, b_2, \ldots, b_i)$$$ is maximized.$$$\textbf{MEX}$$$ of a set of nonnegative integers is the minimal nonnegative integer such that it is not in the set.For example, $$$\textbf{MEX}(\{1, 2, 3\}) = 0$$$, $$$\textbf{MEX}(\{0, 1, 2, 4, 5\}) = 3$$$.

The first line contains a single integer $$$t$$$ $$$(1 \le t \le 100)$$$  — the number of test cases. The first line of each test case contains a single integer $$$n$$$ $$$(1 \le n \le 100)$$$. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ $$$(0 \le a_i \le 100)$$$.

For each test case print an array $$$b_1, b_2, \ldots, b_n$$$  — the optimal reordering of $$$a_1, a_2, \ldots, a_n$$$, so the sum of $$$\textbf{MEX}$$$ on its prefixes is maximized. If there exist multiple optimal answers you can find any.

'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 readline() {
  return inputString[currentLine++];
}

// Make a Snippet for the code above this and then write your logic in main();
var mod = 1000000000n + 7n
var maxN = 1002

function main() {
  const x = readline();
  //
  Array(parseInt(x)).fill(1).map((t, iii) => {
    var n = parseInt(readline())
    // var [n, m] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // });
    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    var ans = []
    var mark = new Array(n).fill(false)
    for (let j = 0; j < 103; j++) {
      for (let k = 0; k < 103; k++) {
        for (let i = 0; i < a.length; i++) {
          if (a[i] === k && !mark[i]) {
            ans.push(a[i])
            mark[i] = true
            break
          }
        }
      }
    }
    console.log(ans.join(' '))
  });

}

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

var standardInputString = "";
var currentLine = 0;

function readline() {
  return standardInputString[currentLine++];
}

process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});

process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  let t = +readline();
  while (t--) {
    let n = +readline();
    let arr = readline()
      .split(" ")
      .map((val) => +val);
    let map = Array.from({ length: 101 }).fill(0);
    let ans = [];
    for (let i = 0; i < arr.length; ++i) {
      map[arr[i]]++;
    }
    for (let i = 0; i <= 100; ++i) {
      if (map[i] > 0) {
        ans.push(i);
        map[i]--;
      }
    }

    for (let i = 0; i <= 100; ++i) {
      for (let j = 0; j < map[i]; ++j) {
        ans.push(i);
      }
    }
    console.log(ans.join(" "));
  }
}

let y = '';
process.stdin.on('data', c => y += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = y.split(EOL);
	var t = lines[0];
	var n = 0;
	for(i = 1; i <= t * 2; i++){
	    if(i % 2 == 1){
	        n = lines[i];
	    }else{
	        var a = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
	        var v = [];
	        var ans = '';
	        for(j = 1; j <= n; j++){
	            if(a[j] != a[j - 1]){
	                ans += a[j - 1] + ' ';
	            }else{
	                v.push(a[j - 1]);
	            }
	        }
	        for(j = 0; j < v.length; j++){
	            ans += v[j] + ' ';
	        }
	        console.log(ans);
	    }
	}
});

let input = '';
process.stdin.on('data', (c) => {
    input += c;
});

process.stdin.on('end', () => {
    const lines = input.split('\n');
    const cases = parseInt(lines[0]);

    let prevLetter;
    for (let i = 2; i < cases * 2 + 1; i += 2) {
        const line = lines[i];
        const numbers = line.split(' ').map(t => parseInt(t.trim()));

        const sorted = numbers.slice().sort((a, b) => a - b);

        const prev = [];
        const append = [];
        for (let j = 0; j < sorted.length; j++) {
            const num = sorted[j];
            if (!prev.includes(num)) {
                prev.push(num);
            } else {
                append.push(num);
            }
        }
        console.log([...prev, ...append].join(' '));
    }
});

process.stdin.setEncoding('utf-8')
const readline = require('readline')

const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    }
)

let count = -1
let inputArr = []

rl.on('line', data => {
    if (count === -1) {
        count = +data * 2
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    // max number 2^(53) - 1 ~~ 10^(15)
    if (count === 0) {
        inputArr = inputArr.map(i => i.split(' ').map(j => +j))
        main()
        process.exit(0)
    }
})

function solve(n, arr) {
    arr.sort((a, b) => a - b)
    const res = [], res2 = []
    let temp = -1
    arr.forEach(i => {
        if (i !== temp) res.push(i)
        else res2.push(i)
        temp = i
    })
    console.log(res.join(' '), res2.join(' '))
}

function main() {
    for (let i = 0; i < inputArr.length; i += 2) solve(inputArr[i][0], inputArr[i + 1])
}

//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{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
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();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var list = nextIntArray(N);
		list.sort(function(a,b){
			return a - b;
		});
		var output = [];
		var ato = [];
		var now = 0;
		for(var j = 0; j < N; j++){
			if(list[j] == now){
				output.push(list[j]);
				now++;
			}else{
				ato.push(list[j]);
			}
		}
		output = output.concat(ato);
		myout(myconv(output, 8));
	}
}

///////////////////////////////// pre-define /////////////////////////////////////
const pr = console.log;
///////////////////////////////////////////////////////////////////////////////////

const solve = (n, a) => {
    let m = new Map();
    for (const e of a) {
        m.set(e, m.get(e) + 1 || 1);
    }
    m = sortMapByKey(m);
    let res = Array.from(m.keys());
    for (const [k, v] of m) {
        if (v == 1) continue;
        for (let i = 1; i <= v - 1; i++) {
            res.push(k);
        }
    }
    pr(res.join(" "));
};

const sortMapByKey = (map) => {
    return new Map([...map].sort((a, b) => a[0] - b[0]));
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    let input = [];
    rl.on('line', (line) => {
        input.push(line.split(" ").map(x => Number(x)));
    });
    rl.on('close', () => {
        let t = input[0][0];
        let i = 1;
        while (t--) {
            solve(input[i][0], input[i + 1]);
            i += 2;
        }
    });
};

main()

var t = parseInt(readline());
while (t--) {
    var mystring = "";
    var n = parseInt(readline());
    var arr = readline().split(" ").map(function(x) {return parseInt(x)});
    var count = new Array(110).fill(0);
    for (var i = Number(0); i < n; i++) {
        count[arr[i]]++;
    }
    for (var i = 0; i < 110; i++) {
        if (count[i] > 0) {
            mystring = mystring + i + " ";
            count[i]--;
        }
    }
    for (var i = 0; i < 110; i++) {
        while (count[i] > 0) {
            mystring = mystring + i + " ";
            count[i]--;
        }
    }
    print(mystring)
}

function getInt(num){
    return parseInt(num, 10)
}

var t = parseInt(readline(), 10);

for(var i = 0; i<t; i++){
    var n = getInt(readline());
    var innerLine = readline().split(' ').map(getInt);
    solution(innerLine);
}
function solution(arr){
    var counters = new Array(100);
    var res = [];

    arr.forEach(function(item){
        counters[item] = (counters[item] || 0) + 1;
    });
    if(!counters[0]){
        print(arr.join(' '))
        return;
    }

    counters.map(function(item, i){
        if(item){
            res.push(i);
            item--;
        }
        return item;
    }).forEach(function(item, i){
        for(var k = 0; k < (item || 0); k++){
            res.push(i);
        }
    })
    print(res.join(' '));
}

'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 readline() {
  return inputString[currentLine++];
}

// Make a Snippet for the code above this and then write your logic in main();
var mod = 1000000000n + 7n
var maxN = 1002

function main() {
  const x = readline();
  //
  Array(parseInt(x)).fill(1).map((t, iii) => {
    var n = parseInt(readline())
    // var [n, m] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // });
    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    var ans = []
    var mark = new Array(n).fill(false)
    for (let j = 0; j < 102; j++) {
      for (let k = 0; k < 100; k++) {
        for (let i = 0; i < a.length; i++) {
          if (a[i] === k && !mark[i]) {
            ans.push(a[i])
            mark[i] = true
            break
          }
        }
      }
    }
    console.log(ans.join(' '))
  });

}

'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 readline() {
  return inputString[currentLine++];
}

// Make a Snippet for the code above this and then write your logic in main();
var mod = 1000000000n + 7n
var maxN = 1002

function main() {
  const x = readline();
  //
  Array(parseInt(x)).fill(1).map((t, iii) => {
    var n = parseInt(readline())
    // var [n, m] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // });
    var a = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    var ans = []
    var mark = new Array(n).fill(false)
    for (let j = 0; j < 100; j++) {
      for (let k = 0; k < 100; k++) {
        for (let i = 0; i < a.length; i++) {
          if (a[i] === k && !mark[i]) {
            ans.push(a[i])
            mark[i] = true
            break
          }
        }
      }
    }
    console.log(ans.join(' '))
  });

}

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

var standardInputString = "";
var currentLine = 0;

function readline() {
  return standardInputString[currentLine++];
}

process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});

process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  let t = +readline();
  while (t--) {
    let n = +readline();
    let arr = readline()
      .split(" ")
      .map((val) => +val);
    let map = Array.from({ length: 101 }).fill(0);
    let ans = [];
    for (let i = 0; i < arr.length; ++i) {
      map[arr[i]]++;
    }
    for (let i = 0; i <= 100; ++i) {
      if (map[i] > 0) {
        ans.push(i);
        map[i]--;
      }
    }

    for (let i = 0; i <= 100; ++i) {
      for (let j = 0; j < map[i]; ++j) {
        ans.push(i);
      }
    }
    console.log(ans);
  }
}

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

var standardInputString = "";
var currentLine = 0;

function readline() {
  return standardInputString[currentLine++];
}

process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});

process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  let t = +readline();
  while (t--) {
    let n = +readline();
    let arr = readline()
      .split(" ")
      .map((val) => +val);
    let count = {};
    for (let i = 0; i < arr.length; ++i) {
      if (count[arr[i]]) count[arr[i]]++;
      else {
        count[arr[i]] = 1;
      }
    }
    let ans = [];
    for (let i = 0; i < arr.length; ++i) {
      if (count[arr[i]] === 1) ans.push(arr[i]);
    }
    for (let i = 0; i < arr.length; ++i) {
      if (count[arr[i]] > 1) ans.push(arr[i]);
    }
    console.log(ans);
  }
}

let y = '';
process.stdin.on('data', c => y += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = y.split(EOL);
	var t = lines[0];
	var e = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            e = lines[i] * 2;
        }else{
            var k = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
            var start = 0;
            var end = e - 1;
            var ans = '';
            while(start < end){
                ans += k[start] + ' ';
                start++;
                if(start > end){
                    break;
                }
                ans += k[end] + ' ';
                end--;
                if(start > end){
                    break;
                }
            }
            console.log(ans);
        }
    }
});

let input = '';
process.stdin.on('data', (c) => {
    input += c;
});

process.stdin.on('end', () => {
    const lines = input.split('\n');
    const cases = parseInt(lines[0]);

    let prevLetter;
    for (let i = 2; i < cases * 2 + 1; i += 2) {
        const line = lines[i];
        const numbers = line.split(' ').map(t => parseInt(t.trim()));

        const sorted = numbers.slice().sort((a, b) => a - b);

        let out = [];
        let prev = [];
        let append = [];
        let final = [];
        for (let j = 0; j < numbers.length; j++) {
            const num = numbers[j];
            if (!prev.includes(num)) {
                prev.push(num);
                out.push(num);
                out.sort((a, b) => a - b);
            } else {
              //  out.push(numbers[j + 1]);
                out.sort((a, b) => a - b);
                append = numbers.slice(j + 1);
                final.push(num);
                break;
            }
        }
        console.log([...out, ...append.sort((a, b) => a - b),  ...final.sort((a, b) => a - b)].join(' '));
    }
});

process.stdin.setEncoding('utf-8')
const readline = require('readline')

const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    }
)

let count = -1
let inputArr = []

rl.on('line', data => {
    if (count === -1) {
        count = +data * 2
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    // max number 2^(53) - 1 ~~ 10^(15)
    if (count === 0) {
        inputArr = inputArr.map(i => i.split(' ').map(j => +j))
        main()
        process.exit(0)
    }
})

function solve(n, arr) {
    arr.sort((a, b) => a - b)
    const res = [], res2 = []
    let temp = -1
    arr.forEach(i => {
        if (i !== temp) res.push(i)
        else res2.push(i)
    })
    console.log(res.join(' '), res2.join(' '))
}

function main() {
    for (let i = 0; i < inputArr.length; i += 2) {
        solve(inputArr[i][0], inputArr[i + 1])
    }
}

//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{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
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();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var list = nextIntArray(N);
		list.sort(function(a,b){
			return a - b;
		});
		myout(myconv(list, 8));
	}
}


You are given a square grid with $$$n$$$ rows and $$$n$$$ columns. Each cell contains either $$$0$$$ or $$$1$$$. In an operation, you can select a cell of the grid and flip it (from $$$0 \to 1$$$ or $$$1 \to 0$$$). Find the minimum number of operations you need to obtain a square that remains the same when rotated $$$0^{\circ}$$$, $$$90^{\circ}$$$, $$$180^{\circ}$$$ and $$$270^{\circ}$$$.The picture below shows an example of all rotations of a grid.

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 100$$$) — the size of the grid. Then $$$n$$$ lines follow, each with $$$n$$$ characters $$$a_{i,j}$$$ ($$$0 \leq a_{i,j} \leq 1$$$) — the number written in each cell.

For each test case output a single integer  — the minimum number of operations needed to make the square look the same rotated $$$0^{\circ}$$$, $$$90^{\circ}$$$, $$$180^{\circ}$$$ and $$$270^{\circ}$$$.

NoteIn the first test case, we can perform one operations to make the grid $$$\begin{matrix}0 & 1 & 0\\ 1 & 1 & \color{red}{1}\\ 0 & 1 & 0\end{matrix}$$$. Now, all rotations of the square are the same.In the second test case, all rotations of the square are already the same, so we don't need any flips.

//Setup
let i = ''
let input;
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
  //console.log(lines);
  input=lines
//Actual Code

    //Input Reading and var config
    var numTests = parseInt(input[0])
    var testCases = []
    var indexReading=1
    while(indexReading<parseInt(input.length)){

        var size = parseInt(input[indexReading])
        var matrix = []
        for(b=0;b<size;b++){
            indexReading++
            matrix.push(input[indexReading].split(""))
        }
        indexReading++
       testCases.push({size:size,matrix:matrix})
    }
    testCases.pop()

    for(c=0;c<testCases.length;c++){
        var caseTesting = testCases[c]
        var ans = 0
        if(caseTesting.size==1){
            ans = 0
        }else{
            var ringsToTest = Math.floor(caseTesting.size/2)

            for(ring=0;ring<ringsToTest;ring++){
                arraysToCompare = [[],[],[],[]]

            for(index=0;index<caseTesting.size-1-(ring*2);index++){
                arraysToCompare[0].push(caseTesting.matrix[ring+index][ring])
                arraysToCompare[1].push(caseTesting.matrix[caseTesting.size-ring-1][ring+index])
                arraysToCompare[2].push(caseTesting.matrix[caseTesting.size-(1+ring+index)][caseTesting.size-(1+ring)])
                arraysToCompare[3].push(caseTesting.matrix[ring][caseTesting.size-(1+ring+index)])
               }
         //Array Comparing
            for(indexChecking=0;indexChecking<caseTesting.size-1-(ring*2);indexChecking++){
                var arrayChecking = [
                    arraysToCompare[0][indexChecking],
                    arraysToCompare[1][indexChecking],
                    arraysToCompare[2][indexChecking],
                    arraysToCompare[3][indexChecking]
                ]
            function numReps(array, element) {
                var reps = 0;
                array.forEach((valor) => (valor === element && reps++));
                return reps;
            }
            if(numReps(arrayChecking,"0")-numReps(arrayChecking,"1")==2 ||
            numReps(arrayChecking,"0")-numReps(arrayChecking,"1")==-2
            ){
                ans+=1
            }
            if(numReps(arrayChecking,"0")-numReps(arrayChecking,"1")==0){
                ans+=2
            }
         }

        }
        }

        console.log(ans)

    }

})

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 = +lines[l++]
        const arr = lines.slice(l, l + n).map(str => str.trim())
        l += n
        output[i] = solve(n, arr)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, arr) {
    let ans = 0
    const limit = Math.ceil(n / 2)
    for (let i = 0; i < limit; i++) {
        const t1 = []
        const t2 = []
        const t3 = []
        const t4 = []
        for (let j = 0; j < n - 1 - i * 2; j++) {
            // t1.push(arr[i][i + j])
            // t2.push(arr[i + j][n - 1 - i])
            // t3.push(arr[n - 1 - i][n - 1 - i - j])
            // t4.push(arr[n - 1 - i - j][i])
            const temp = [
                arr[i][i + j],
                arr[i + j][n - 1 - i],
                arr[n - 1 - i][n - 1 - i - j],
                arr[n - 1 - i - j][i]
            ]
            ans += cal(temp)
        }
            // console.log(t1, t2, t3, t4)
    }
    return ans
}
function cal(temp) {
    // console.log(temp)
    let c0 = 0, c1 = 0
    temp.forEach(x => {
        if (x === '0') c0++
        if (x === '1') c1++
    })
    return Math.min(c0, c1)
}

'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 readline() {
    return inputString[currentLine++];
}

function output(x) {
    if (typeof x !== 'string') {
        x = x.toString();
    }
    //process.stdout.write(x);   // without auto '\n' (newline)
    console.log(x);  // with auto '\n' (newline)
}

function main() {
    let N = readline();

    for (let test = 0; test < N; test++) {
        let n = readline();
        let grid = [];
        for (let i = 0; i < n; i++) {
            grid[i] = readline().split('').map(Number);
        }

        let endLeft = Math.floor(n / 2);
        let endTop = Math.ceil(n / 2);

        const getAllSym = (row, col, n) => {
            // ROW, COLUMN
            return [
                [row, col],
                [col, n - row - 1],
                [n - row - 1, n - col - 1],
                [n - col - 1, row]
            ];
        }

        let steps = sum => {
            if (sum === 0 || sum === 4) {
                return 0;
            } else if (sum === 1 || sum === 3) {
                return 1;
            } else {
                return 2;
            }
        };

        let sumAllSym = (points, grid) => {
            return grid[points[0][0]][points[0][1]]
                + grid[points[1][0]][points[1][1]]
                + grid[points[2][0]][points[2][1]]
                + grid[points[3][0]][points[3][1]];
        };

        let res = 0;
        for (let left = 0; left < endLeft; left++) {
            for (let top = 0; top < endTop; top++) {
                let allSym = getAllSym(left, top, n);
                let sum = sumAllSym(allSym, grid);
                res += steps(sum);
            }
        }

        output(res);
    }
}

//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();
	while(hasNext()){
		var N = nextInt();
		var list = new Array(N);
		for(var i = 0; i < N; i++){
			list[i] = nextCharArray();
		}
		var output = 0;
		for(var i = 0; i < N; i++){
			for(var j = 0; j < N; j++){
				var zero = 0;
				var one = 0;
				var x = i + 1;
				var y = j + 1;
				for(var k = 0; k < 4; k++){
					if(list[y - 1][x - 1] == "1"){
						one++;
					}else{
						zero++;
					}
					var tmp = x;
					x = y;
					y = N - tmp + 1;
				}
				output += Math.min(one, zero);
				for(var k = 0; k < 4; k++){
					list[y - 1][x - 1] = "1";
					var tmp = x;
					x = y;
					y = N - tmp + 1;
				}
			}
		}
		myout(output);
	}
}

var t = parseInt(readline());

var rotatedCoord = function (coord, n) {
    return [coord[1], n - 1 - coord[0]];
}

for (var k = 0; k < t; k++) {
    var n = parseInt(readline());
    var matr = [];
    var ans = 0;

    for (var p = 0; p < n; p++) {
        var str = readline();
        matr.push(str);
    }

    if (n === 1) {
        print(0);
        continue;
    }

    for (var i = 0; i < (n-1)/2; i++) {
        for (var j = 0; j < n/2; j++) {
            var coord90 = rotatedCoord([i, j], n);
            var coord180 = rotatedCoord(coord90, n);
            var coord270 = rotatedCoord(coord180, n);

            var kit = [
                matr[i][j],
                matr[coord90[0]][coord90[1]],
                matr[coord180[0]][coord180[1]],
                matr[coord270[0]][coord270[1]]
            ];

            var count0 = 0;
            var count1 = 0;
            kit.forEach(item => {
                if (item === '0') {
                    count0++;
                } else {
                    count1++;
                }
            })

            ans += Math.min(count0, count1);
        }
    }

    print(ans);
}

var tests = parseInt(readline());
    for (var t=0; t<tests;t++) {
        var n = parseInt(readline());
        var m = [];
        for (var i =0; i < n; i++) {
            m.push(readline().split('').map(x=>parseInt(x)));
        }
        var mid = Math.floor((n+1)/2);
        var ans = 0;
        for (var r = 0; r < mid; r++) {
            if (n & 1 && r == mid-1) {
                continue;
            }
            for (var c = 0; c < mid; c++) {
                var sum = m[r][c] + m[c][n-r-1] + m[n-c-1][r] + m[n-r-1][n-c-1];
                ans += Math.min(sum, 4-sum);

            }
        }
        print(ans);
    }

//Setup
let i = ''
let input;
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
  //console.log(lines);
  input=lines
//Actual Code

    //Input Reading and var config
    var numTests = parseInt(input[0])
    var testCases = []
    var indexReading=1
    while(indexReading<parseInt(input.length)){

        var size = parseInt(input[indexReading])
        var matrix = []
        for(b=0;b<size;b++){
            indexReading++
            matrix.push(input[indexReading].split(""))
        }
        indexReading++
       testCases.push({size:size,matrix:matrix})
    }
    testCases.length==numTests

    for(c=0;c<testCases.length;c++){
        var caseTesting = testCases[c]
        var ans = 0
        if(caseTesting.size==1){
            ans = 0
        }else{
            var ringsToTest = Math.floor(caseTesting.size/2)

            for(ring=0;ring<ringsToTest;ring++){
                arraysToCompare = [[],[],[],[]]

            for(index=0;index<caseTesting.size-1-(ring*2);index++){
                arraysToCompare[0].push(caseTesting.matrix[ring+index][ring])
                arraysToCompare[1].push(caseTesting.matrix[caseTesting.size-ring-1][ring+index])
                arraysToCompare[2].push(caseTesting.matrix[caseTesting.size-(1+ring+index)][caseTesting.size-(1+ring)])
                arraysToCompare[3].push(caseTesting.matrix[ring][caseTesting.size-(1+ring+index)])
               }
         //Array Comparing
            for(indexChecking=0;indexChecking<caseTesting.size-1-(ring*2);indexChecking++){
                var arrayChecking = [
                    arraysToCompare[0][indexChecking],
                    arraysToCompare[1][indexChecking],
                    arraysToCompare[2][indexChecking],
                    arraysToCompare[3][indexChecking]
                ]
            function numReps(array, element) {
                var reps = 0;
                array.forEach((valor) => (valor === element && reps++));
                return reps;
            }
            if(numReps(arrayChecking,"0")-numReps(arrayChecking,"1")==2 ||
            numReps(arrayChecking,"0")-numReps(arrayChecking,"1")==-2
            ){
                ans+=1
            }
            if(numReps(arrayChecking,"0")-numReps(arrayChecking,"1")==0){
                ans+=2
            }
         }

        }
        }

        console.log(ans)

    }

})

//Setup
let i = ''
let input;
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
  //console.log(lines);
  input=lines
//Actual Code

    //Input Reading and var config
    var numTests = parseInt(input[0])
    var testCases = []
    var indexReading=1
    while(indexReading<parseInt(input.length)){

        var size = parseInt(input[indexReading])
        var matrix = []
        for(b=0;b<size;b++){
            indexReading++
            matrix.push(input[indexReading].split(""))
        }
        indexReading++
       testCases.push({size:size,matrix:matrix})
    }
    console.log(testCases)
    for(c=0;c<testCases.length;c++){
        var caseTesting = testCases[c]
        var ans = 0
        if(caseTesting.size==1){
            ans = 0
        }else{
            var ringsToTest = Math.floor(caseTesting.size/2)

            for(ring=0;ring<ringsToTest;ring++){
                arraysToCompare = [[],[],[],[]]

            for(index=0;index<caseTesting.size-1-(ring*2);index++){
                arraysToCompare[0].push(caseTesting.matrix[ring+index][ring])
                arraysToCompare[1].push(caseTesting.matrix[caseTesting.size-ring-1][ring+index])
                arraysToCompare[2].push(caseTesting.matrix[caseTesting.size-(1+ring+index)][caseTesting.size-(1+ring)])
                arraysToCompare[3].push(caseTesting.matrix[ring][caseTesting.size-(1+ring+index)])
               }
         //Array Comparing
            for(indexChecking=0;indexChecking<caseTesting.size-1-(ring*2);indexChecking++){
                var arrayChecking = [
                    arraysToCompare[0][indexChecking],
                    arraysToCompare[1][indexChecking],
                    arraysToCompare[2][indexChecking],
                    arraysToCompare[3][indexChecking]
                ]
            function numReps(array, element) {
                var reps = 0;
                array.forEach((valor) => (valor === element && reps++));
                return reps;
            }
            if(numReps(arrayChecking,"0")-numReps(arrayChecking,"1")==2 ||
            numReps(arrayChecking,"0")-numReps(arrayChecking,"1")==-2
            ){
                ans+=1
            }
            if(numReps(arrayChecking,"0")-numReps(arrayChecking,"1")==0){
                ans+=2
            }
         }

        }
        }

        console.log(ans)

    }

})

//Setup
let i = ''
let input;
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
  //console.log(lines);
  input=lines
//Actual Code

    //Input Reading and var config
    var numTests = parseInt(input[0])
    var testCases = []
    var indexReading=1
    while(indexReading<parseInt(input.length)){

        var size = parseInt(input[indexReading])
        var matrix = []
        for(c=0;c<size;c++){
            indexReading++
            matrix.push(input[indexReading].split(""))
        }
        indexReading++
       testCases.push({size:size,matrix:matrix})
    }
    console.log(testCases)
    for(c=0;c<testCases.length;c++){
        var caseTesting = testCases[c]
        var ans = 0
        if(caseTesting.size==1){
            ans = 0
        }else{
            var ringsToTest = Math.floor(caseTesting.size/2)

            for(ring=0;ring<ringsToTest;ring++){
                arraysToCompare = [[],[],[],[]]

            for(index=0;index<caseTesting.size-1-(ring*2);index++){
                arraysToCompare[0].push(caseTesting.matrix[ring+index][ring])
                arraysToCompare[1].push(caseTesting.matrix[caseTesting.size-ring-1][ring+index])
                arraysToCompare[2].push(caseTesting.matrix[caseTesting.size-(1+ring+index)][caseTesting.size-(1+ring)])
                arraysToCompare[3].push(caseTesting.matrix[ring][caseTesting.size-(1+ring+index)])
               }
         //Array Comparing
            for(indexChecking=0;indexChecking<caseTesting.size-1-(ring*2);indexChecking++){
                var arrayChecking = [
                    arraysToCompare[0][indexChecking],
                    arraysToCompare[1][indexChecking],
                    arraysToCompare[2][indexChecking],
                    arraysToCompare[3][indexChecking]
                ]
            function numReps(array, element) {
                var reps = 0;
                array.forEach((valor) => (valor === element && reps++));
                return reps;
            }
            if(numReps(arrayChecking,"0")-numReps(arrayChecking,"1")==2 ||
            numReps(arrayChecking,"0")-numReps(arrayChecking,"1")==-2
            ){
                ans+=1
            }
            if(numReps(arrayChecking,"0")-numReps(arrayChecking,"1")==0){
                ans+=2
            }
         }

        }
        }

        console.log(ans)

    }

})

//Setup
let i = ''
let input;
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
  //console.log(lines);
  input=lines
//Actual Code
//Actual Code

    //Input Reading and var config
    var numTests = parseInt(input[0])
    var testCases = []
    var indexReading=1
    while(indexReading<parseInt(input.length)){

        var size = parseInt(input[indexReading])
        var matrix = []
        for(c=0;c<size;c++){
            indexReading++
            matrix.push(input[indexReading].split(""))
        }
        indexReading++
       testCases.push({size:size,matrix:matrix})
    }

    for(c=0;c<testCases.length;c++){
        var caseTesting = testCases[c]
        var ans = 0
        if(caseTesting.size==1){
            ans = 0
        }else{
            var ringsToTest = Math.floor(caseTesting.size/2)

            for(ring=0;ring<ringsToTest;ring++){
                arraysToCompare = [[],[],[],[]]

            for(index=0;index<caseTesting.size-1-(ring*2);index++){
                arraysToCompare[0].push(caseTesting.matrix[ring+index][ring])
                arraysToCompare[1].push(caseTesting.matrix[caseTesting.size-ring-1][ring+index])
                arraysToCompare[2].push(caseTesting.matrix[caseTesting.size-(1+ring+index)][caseTesting.size-(1+ring)])
                arraysToCompare[3].push(caseTesting.matrix[ring][caseTesting.size-(1+ring+index)])
               }
         //Array Comparing
            for(indexChecking=0;indexChecking<caseTesting.size-1-(ring*2);indexChecking++){
                var arrayChecking = [
                    arraysToCompare[0][indexChecking],
                    arraysToCompare[1][indexChecking],
                    arraysToCompare[2][indexChecking],
                    arraysToCompare[3][indexChecking]
                ]
            function numReps(array, element) {
                var reps = 0;
                array.forEach((valor) => (valor === element && reps++));
                return reps;
            }
            if(numReps(arrayChecking,"0")-numReps(arrayChecking,"1")==2 ||
            numReps(arrayChecking,"0")-numReps(arrayChecking,"1")==-2
            ){
                ans+=1
            }
            if(numReps(arrayChecking,"0")-numReps(arrayChecking,"1")==0){
                ans+=2
            }
         }

        }
        }

        console.log(ans)

    }

})

//Setup
let i = ''
let input;
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
  //console.log(lines);
  input=lines
//Actual Code

    //Input Reading and var config
    var numTests = parseInt(input[0])
    var testCases = []
    var indexReading=1
    while(indexReading<parseInt(input.length)){

        var size = parseInt(input[indexReading])
        var matrix = []
        for(c=0;c<size;c++){
            indexReading++
            matrix.push(input[indexReading].split(""))
        }
        indexReading++
       testCases.push({size:size,matrix:matrix})
    }

    for(c=0;c<testCases.length;c++){
        var caseTesting = testCases[c]
        var ans = 0
        if(caseTesting.size==1){
            ans = 0
        }else{
            var ringsToTest = Math.floor(caseTesting.size/2)

            for(ring=0;ring<ringsToTest;ring++){
                arraysToCompare = [[],[],[],[]]

            for(index=0;index<caseTesting.size-1-(ring*2);index++){
                arraysToCompare[0].push(caseTesting.matrix[ring+index][ring])
                arraysToCompare[1].push(caseTesting.matrix[caseTesting.size-ring-1][ring+index])
                arraysToCompare[2].push(caseTesting.matrix[caseTesting.size-(1+ring+index)][caseTesting.size-(1+ring)])
                arraysToCompare[3].push(caseTesting.matrix[ring][caseTesting.size-(1+ring+index)])
               }
         //Array Comparing
            for(indexChecking=0;indexChecking<caseTesting.size-1-(ring*2);indexChecking++){
                var arrayChecking = [
                    arraysToCompare[0][indexChecking],
                    arraysToCompare[1][indexChecking],
                    arraysToCompare[2][indexChecking],
                    arraysToCompare[3][indexChecking]
                ]
            function numReps(array, element) {
                var reps = 0;
                array.forEach((valor) => (valor === element && reps++));
                return reps;
            }
            if(numReps(arrayChecking,"0")-numReps(arrayChecking,"1")==2 ||
            numReps(arrayChecking,"0")-numReps(arrayChecking,"1")==-2
            ){
                ans+=1
            }
            if(numReps(arrayChecking,"0")-numReps(arrayChecking,"1")==0){
                ans+=2
            }
         }

        }
        }

        console.log(ans)

    }
})

var t = parseInt(readline());

var rotatedCoord = function (coord, n) {
    return [coord[1], n - 1 - coord[0]];
}

for (var k = 0; k < t; k++) {
    var n = parseInt(readline());
    var matr = [];
    var ans = 0;

    for (var p = 0; p < n; p++) {
        var str = readline();
        matr.push(str.split(' '));
    }

    if (n === 1) {
        print(0);
        continue;
    }

    for (var i = 0; i < (n-1)/2; i++) {
        for (var j = 0; j < n/2; j++) {
            var coord90 = rotatedCoord([i, j], n);
            var coord180 = rotatedCoord(coord90, n);
            var coord270 = rotatedCoord(coord180, n);

            var kit = [
                matr[i][j],
                matr[coord90[0]][coord90[1]],
                matr[coord180[0]][coord180[1]],
                matr[coord270[0]][coord270[1]]
            ];

            var count0 = 0;
            var count1 = 0;
            kit.forEach(item => {
                parseInt(item) === 0 && count0++;
                parseInt(item) === 1 && count1++;
            })

            ans += Math.min(count0, count1);
        }
    }

    print(ans);
}

var t = parseInt(readline());

var rotatedCoord = function (coord, n) {
    return [coord[1], n - 1 - coord[0]];
}

for (var k = 0; k < t; k++) {
    var n = parseInt(readline());
    var matr = [];
    var ans = 0;

    for (var p = 0; p < n; p++) {
        var str = readline();
        matr.push(str);
    }
    print(matr);

    if (n === 1) {
        print(0);
        continue;
    }

    for (var i = 0; i < n/2; i++) {
        for (var j = 0; j < n/2 + n%2; j++) {
            var coord90 = rotatedCoord([i, j], n);
            var coord180 = rotatedCoord(coord90, n);
            var coord270 = rotatedCoord(coord180, n);

            var kit = [
                matr[i][j],
                matr[coord90[0]][coord90[1]],
                matr[coord180[0]][coord180[1]],
                matr[coord270[0]][coord270[1]]
            ];

            print(kit);

            var count0 = 0;
            var count1 = 0;
            kit.forEach(item => {
                if (item === '0') {
                    count0++;
                } else {
                    count1++;
                }
            })

            ans += Math.min(count0, count1);
        }
    }

    print(ans);
}

var t = parseInt(readline());

var rotatedCoord = function (coord, n) {
    return [coord[1], n - 1 - coord[0]];
}

for (var k = 0; k < t; k++) {
    var n = parseInt(readline());
    var matr = [];
    var ans = 0;

    for (var p = 0; p < n; p++) {
        var str = readline();
        matr.push(str.split(''));
    }

    if (n === 1) {
        print(0);
        continue;
    }

    for (var i = 0; i < n/2; i++) {
        for (var j = 0; j < n/2 + n%2; j++) {
            var coord90 = rotatedCoord([i, j], n);
            var coord180 = rotatedCoord(coord90, n);
            var coord270 = rotatedCoord(coord180, n);

            var kit = [
                matr[i][j],
                matr[coord90[0]][coord90[1]],
                matr[coord180[0]][coord180[1]],
                matr[coord270[0]][coord270[1]]
            ];

            var kitSum = kit.reduce((sum, elem) => sum + parseInt(elem), 0);

            ans += Math.min(kitSum, 4 - kitSum);
        }
    }

    print(ans);
}

var t = parseInt(readline());

var rotatedCoord = function (coord, n) {
    return [coord[1], n - 1 - coord[0]];
}

for (var k = 0; k < t; k++) {
    var n = parseInt(readline());
    var matr = [];
    var ans = 0;

    for (var p = 0; p < n; p++) {
        var str = readline();
        matr.push(str);
    }

    if (n === 1) {
        print(0);
        continue;
    }

    for (var i = 0; i < n/2; i++) {
        for (var j = 0; j < n/2 + n%2; j++) {
            var coord90 = rotatedCoord([i, j], n);
            var coord180 = rotatedCoord(coord90, n);
            var coord270 = rotatedCoord(coord180, n);

            var kit = [
                matr[i][j],
                matr[coord90[0]][coord90[1]],
                matr[coord180[0]][coord180[1]],
                matr[coord270[0]][coord270[1]]
            ];

            var count0 = 0;
            var count1 = 0;
            kit.forEach(item => {
                if (item === '0') {
                    count0++;
                } else {
                    count1++;
                }
            })

            ans += Math.min(count0, count1);
        }
    }

    print(ans);
}

var t = parseInt(readline());

var rotatedCoord = function (coord, n) {
    return [coord[1], n - 1 - coord[0]];
}

for (var k = 0; k < t; k++) {
    var n = parseInt(readline());
    var matr = [];
    var ans = 0;

    for (var p = 0; p < n; p++) {
        var str = readline();
        matr.push(str.split(''));
    }

    if (n === 1) {
        print(0);
        continue;
    }

    for (var i = 0; i < n/2; i++) {
        for (var j = 0; j < n/2 + n%2; j++) {
            var coord90 = rotatedCoord([i, j], n);
            var coord180 = rotatedCoord(coord90, n);
            var coord270 = rotatedCoord(coord180, n);

            var kit = [
                matr[i][j],
                matr[coord90[0]][coord90[1]],
                matr[coord180[0]][coord180[1]],
                matr[coord270[0]][coord270[1]]
            ];

            var kitSum = kit.reduce((sum, elem) => sum + parseInt(elem), 0);

            ans += Math.min(kitSum, n - kitSum);
        }
    }

    print(ans);
}

var t = parseInt(readline());

var rotatedCoord = function (coord, n) {
    return [coord[1], n - 1 - coord[0]];
}

for (var k = 0; k < t; k++) {
    var n = parseInt(readline());
    var matr = [];
    var ans = 0;

    for (var p = 0; p < n; p++) {
        var str = readline();
        matr.push(str.split(' '));
    }

    if (n === 1) {
        print(0);
        continue;
    }

    for (var i = 0; i < n/2 + n%2; i++) {
        for (var j = 0; j < n/2 + n%2; j++) {
            var coord90 = rotatedCoord([i, j], n);
            var coord180 = rotatedCoord(coord90, n);
            var coord270 = rotatedCoord(coord180, n);

            var kit = [
                matr[i][j],
                matr[coord90[0]][coord90[1]],
                matr[coord180[0]][coord180[1]],
                matr[coord270[0]][coord270[1]]
            ];

            var count0 = 0;
            var count1 = 0;
            kit.forEach(item => {
                parseInt(item) === 0 && count0++;
                parseInt(item) === 1 && count1++;
            })

            ans += Math.min(count0, count1);
        }
    }

    print(ans);
}

var t = parseInt(readline());

var rotatedCoord = function (coord, n) {
    return [coord[1], n - 1 - coord[0]];
}

for (var k = 0; k < t; k++) {
    var n = parseInt(readline());
    var matr = [];
    var ans = 0;

    for (var p = 0; p < n; p++) {
        var str = readline();
        matr.push(str.split(' '));
    }

    if (n === 1) {
        print(0);
        continue;
    }

    for (var i = 0; i < n/2; i++) {
        for (var j = 0; j < n/2 + n%2; j++) {
            var coord90 = rotatedCoord([i, j], n);
            var coord180 = rotatedCoord(coord90, n);
            var coord270 = rotatedCoord(coord180, n);

            var kit = [
                matr[i][j],
                matr[coord90[0]][coord90[1]],
                matr[coord180[0]][coord180[1]],
                matr[coord270[0]][coord270[1]]
            ];

            var count0 = 0;
            var count1 = 0;
            kit.forEach(item => {
                parseInt(item) === 0 && count0++;
                parseInt(item) === 1 && count1++;
            })

            ans += Math.min(count0, count1);
        }
    }

    print(ans);
}

var t = parseInt(readline());

var rotatedCoord = function (coord, n) {
    return [coord[1], n - 1 - coord[0]];
}

for (var k = 0; k < t; k++) {
    var n = parseInt(readline());
    var matr = [];
    var ans = 0;

    for (var p = 0; p < n; p++) {
        var str = readline();
        matr.push(str.split(' '));
    }

    if (n === 1) {
        print(0);
        continue;
    }

    for (var i = 0; i < n/2; i++) {
        for (var j = 0; j < n/2 + n%2; j++) {
            var coord90 = rotatedCoord([i, j], n);
            var coord180 = rotatedCoord(coord90, n);
            var coord270 = rotatedCoord(coord180, n);

            var kit = [
                matr[i][j],
                matr[coord90[0]][coord90[1]],
                matr[coord180[0]][coord180[1]],
                matr[coord270[0]][coord270[1]]
            ];

            var count0 = 0;
            var count1 = 0;
            kit.forEach(item => {
                if (item == 0) {
                    count0++;
                } else {
                    count1++;
                }
            })

            ans += Math.min(count0, count1);
        }
    }

    print(ans);
}

var t = parseInt(readline());

var rotatedCoord = function (coord, n) {
    return [coord[1], n - 1 - coord[0]];
}

for (var k = 0; k < t; k++) {
    var n = parseInt(readline());
    var matr = [];
    var ans = 0;

    for (var p = 0; p < n; p++) {
        var str = readline();
        matr.push(str.split(' '));
    }

    if (n === 1) {
        print(0);
        continue;
    }

    for (var i = 0; i < n/2; i++) {
        for (var j = 0; j < n/2 + n%2; j++) {
            var coord90 = rotatedCoord([i, j], n);
            var coord180 = rotatedCoord(coord90, n);
            var coord270 = rotatedCoord(coord180, n);

            var kit = [
                matr[i][j],
                matr[coord90[0]][coord90[1]],
                matr[coord180[0]][coord180[1]],
                matr[coord270[0]][coord270[1]]
            ];

            var count0 = 0;
            var count1 = 0;
            kit.forEach(item => {
                if (parseInt(item) === 0) {
                    count0++;
                } else {
                    count1++;
                }
            })

            ans += Math.min(count0, count1);
        }
    }

    print(ans);
}

var t = parseInt(readline());

var rotatedCoord = function (coord, n) {
    return [coord[1], n - 1 - coord[0]];
}

for (var k = 0; k < t; k++) {
    var n = parseInt(readline());
    var matr = [];
    var ans = 0;

    for (var p = 0; p < n; p++) {
        var str = readline();
        matr.push(str.split(' '));
    }

    if (n === 1) {
        print(0);
        continue;
    }

    for (var i = 0; i < n/2; i++) {
        for (var j = 0; j < n/2 + n%2; j++) {
            var coord90 = rotatedCoord([i, j], n);
            var coord180 = rotatedCoord(coord90, n);
            var coord270 = rotatedCoord(coord180, n);

            var kit = [
                matr[i][j],
                matr[coord90[0]][coord90[1]],
                matr[coord180[0]][coord180[1]],
                matr[coord270[0]][coord270[1]]
            ];

            var count0 = 0;
            var count1 = 0;

            for (var p = 0; p < kit.length; p++) {
                if (parseInt(kit[p]) === 0) {
                    count0++;
                } else {
                    count1++;
                }
            }

            ans += Math.min(count0, count1);
        }
    }

    print(ans);
}

var t = parseInt(readline());

var rotatedCoord = function (coord, n) {
    return [coord[1], n - 1 - coord[0]];
}

for (var k = 0; k < t; k++) {
    var n = parseInt(readline());
    var matr = [];
    var ans = 0;

    for (var p = 0; p < n; p++) {
        var str = readline();
        matr.push(str.split(' '));
    }

    if (n === 1) {
        print(0);
        continue;
    }

    for (var i = 0; i < n/2; i++) {
        for (var j = 0; j < n/2 + n%2; j++) {
            var coord90 = rotatedCoord([i, j], n);
            var coord180 = rotatedCoord(coord90, n);
            var coord270 = rotatedCoord(coord180, n);

            var kit = [
                matr[i][j],
                matr[coord90[0]][coord90[1]],
                matr[coord180[0]][coord180[1]],
                matr[coord270[0]][coord270[1]]
            ];

            var count0 = 0;
            var count1 = 0;
            kit.forEach(item => {
                if (item === '0') {
                    count0++;
                } else {
                    count1++;
                }
            })

            ans += Math.min(count0, count1);
        }
    }

    print(ans);
}

var t = parseInt(readline());

var rotatedCoord = function (coord, n) {
    return [coord[1], n - 1 - coord[0]];
}

for (var k = 0; k < t; k++) {
    var n = parseInt(readline());
    var matr = [];
    var ans = 0;

    for (var p = 0; p < n; p++) {
        var str = readline();
        matr.push(str.split(' '));
    }

    if (n === 1) {
        print(0);
        continue;
    }

    for (var i = 0; i < n/2; i++) {
        for (var j = 0; j < n/2 + n%2; j++) {
            var coord90 = rotatedCoord([i, j], n);
            var coord180 = rotatedCoord(coord90, n);
            var coord270 = rotatedCoord(coord180, n);

            var kit = [
                matr[i][j],
                matr[coord90[0]][coord90[1]],
                matr[coord180[0]][coord180[1]],
                matr[coord270[0]][coord270[1]]
            ];

            var count0 = 0;
            var count1 = 0;
            kit.forEach(item => {
                if (item === 0) {
                    count0++;
                } else {
                    count1++;
                }
            })

            ans += Math.min(count0, count1);
        }
    }

    print(ans);
}

var tests = parseInt(readline());
    for (var t=0; t<tests;t++) {
        var n = parseInt(readline());
        var m = [];
        for (var i =0; i < n; i++) {
            m.push(readline().split('').map(x=>parseInt(x)));
        }
        var mid = (n+1)/2;
        var ans = 0;
        for (var r = 0; r < mid; r++) {
            if (n & 1 && r == mid-1) {
                continue;
            }
            for (var c = 0; c < mid; c++) {
                var sum = m[r][c] + m[c][n-r-1] + m[n-c-1][r] + m[n-r-1][n-c-1];
                ans += Math.min(sum, 4-sum);

            }
        }
        print(ans);
    }

var tests = parseInt(readline());
    for (var t=0; t<tests;t++) {
        var n = parseInt(readline());
        var m = [];
        for (var i =0; i < n; i++) {
            m.push(readline().split('').map(x=>parseInt(x)));
        }
        var mid = (n+1)/2;
        var ans = 0;
        for (var r = 0; r < mid; r++) {
            for (var c = 0; c < mid; c++) {
                if (n & 1 && r == mid-1) {
                    continue;
                }
                var sum = m[r][c] + m[c][n-r-1] + m[n-c-1][r] + m[n-r-1][n-c-1];
                ans += Math.min(sum, 4-sum);

            }
        }
        print(ans);
    }