using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Vestigium { public static int countFreq(int[] arr, int n) { for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (arr[i] == arr[j]) { return 1; } } } return 0; } public static int getoutPut(int[, ] arr1, int n) { int k = 0; for (int i = 0; i < n; i++) { k += arr1[i, i]; } return k; } } class Solution { public static void Main() { try { int t = Convert.ToInt32(Console.ReadLine()); for (int tc = 0; tc < t; tc++) { int n = Convert.ToInt32(Console.ReadLine()); int[, ] arr1 = new int[n, n]; for (int index = 0; index < n; index++) { string str = Console.ReadLine(); string[] strArr = str.Split(' '); for (int j = 0; j < n; j++) { arr1[index, j] = Convert.ToInt32(strArr[j]); } } int k = Vestigium.getoutPut(arr1, n); int[] arr2 = new int[n]; int r = 0; int c = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { arr2[j] = arr1[i, j]; } int check = Vestigium.countFreq(arr2, n); if (check > 0) { r += 1; } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { arr2[j] = arr1[j, i]; } int check = Vestigium.countFreq(arr2, n); if (check > 0) { c += 1; } } Console.WriteLine("Case #" + (tc + 1).ToString() + ": " + k.ToString() + " " + r.ToString() + " " + c.ToString()); } } catch (Exception E) { Console.WriteLine(E.Message); } } }