// Arup Guha
// 4/21/2015
// Alternate Solution to CPU using Prim's

public class cpu2 {

    public static void main(String[] args) {

        Scanner stdin = new Scanner(System.in);
        int numCases = stdin.nextInt();

        // Go through each case.
        for (int loop=1; loop<=numCases; loop++) {

            // Read in the graph.
            int n = stdin.nextInt();
            int[][] adj = new int[n][n];
            for (int i=0; i<n; i++)
                for (int j=0; j<n; j++)
                    adj[i][j] = stdin.nextInt();

            // Solve and output result.
            System.out.println("Design "+loop+": "+mst(adj,n)+" micrometers");
        }
    }

    // Runs Prim's algorithm on the graph stored in adj. adj must be size n x n.
    public static int solve(int[][] adj, int n) {

        // Set up Priority Queue for Prim's.
        PriorityQueue<edge> pqueue = new PriorityQueue<edge>();

        // Just start at vertex 0.
        boolean[] used = new boolean[n];
        used[0] = true;
        int curTree = 0, curSize = 0;

        // Initial edges in the priority queue.
        for (int i=1; i<n; i++)
            pqueue.offer(new edge(0, i, adj[0][i]));

        // Loop until our tree is full.
        while (curSize < n-1) {

            // Get the next edge.
            edge next = pqueue.poll();

            // Will cause a cycle.
            if (used[next.v1] && used[next.v2]) continue;

            // Next vertex added.
            int newV = used[next.v1] ? next.v2 : next.v1;
            used[newV] = true;

            // Update our MST.
            curSize++;
            curTree += next.w;

            // Enqueue all new edges into Priority Queue.
            for (int i=0; i<n; i++)
                if (!used[i])
                    pqueue.offer(new edge(newV, i, adj[newV][i]));
        }

        // Here is our answer.
        return curTree;
    }
}

class edge implements Comparable<edge> {

    public int v1;
    public int v2;
    public int w;

    public edge(int start, int end, int weight) {
        v1 = start;
        v2 = end;
        w = weight;
    }

    public int compareTo(edge other) {
        return this.w - other.w;
    }
}
