public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); MyReader reader = new MyReader(br); MyPrinter printer = new MyPrinter(); Mice mice; String str; String output; while ((str = br.readLine()) != null) { int count = Integer.parseInt(str); for (int i = 0; i < count; i++) { int side = reader.getSide(); int[][] square = reader.getSquare(side); mice = new Mice(); output = mice.getLongestDistance(square) + ""; if (i != count - 1) { output += "\n"; } out.println(output); } } }