Problem: You have a rectangular chocolate bar consisting of n × m single squares. You want to eat exactly k squares, so you may need to break the chocolate bar. 

In one move you can break any single rectangular piece of chocolate in two rectangular pieces. You can break only by lines between squares: horizontally or vertically. The cost of breaking is equal to square of the break length.

For example, if you have a chocolate bar consisting of 2 × 3 unit squares then you can break it horizontally and get two 1 × 3 pieces (the cost of such breaking is 32 = 9), or you can break it vertically in two ways and get two pieces: 2 × 1 and 2 × 2 (the cost of such breaking is 22 = 4).

For several given values n, m and k find the minimum total cost of breaking. You can eat exactly k squares of chocolate if after all operations of breaking there is a set of rectangular pieces of chocolate with the total size equal to k squares. The remaining n·m - k squares are not necessarily form a single rectangular piece.

Input

The first line of the input contains a single integer t (1 ≤ t ≤ 40910) — the number of values n, m and k to process.

Each of the next t lines contains three integers n, m and k (1 ≤ n, m ≤ 30, 1 ≤ k ≤ min(n·m, 50)) — the dimensions of the chocolate bar and the number of squares you want to eat respectively.

Output

For each n, m and k print the minimum total cost needed to break the chocolate bar, in order to make it possible to eat exactly k squares.

Examples

Input

4
2 2 1
2 2 3
2 2 2
2 2 4


Output

5
5
4
0

Note

In the first query of the sample one needs to perform two breaks:

  * to split 2 × 2 bar into two pieces of 2 × 1 (cost is 22 = 4), 
  * to split the resulting 2 × 1 into two 1 × 1 pieces (cost is 12 = 1). 



In the second query of the sample one wants to eat 3 unit squares. One can use exactly the same strategy as in the first query of the sample.

Solution (in JAVA):

Solution:
/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class ChocolateBar {
    public static void main(String args[]) throws Exception {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        int T = sc.nextInt();

        int oo = (int) 1e9;
        int[][][] dp = new int[31][31][51];
        // dp[w][h][k] = minimum cost to break into parts that sum to k starting
        // from a bar w x h.
        for (int w = 0; w <= 30; w++) {
            for (int h = 0; h <= 30; h++) {
                // Everything else is impossible
                // If w * h < k, we can't possibly fill it
                // If w * h > k, we need to go to subproblems with smaller w, h
                // If w * h == k, then we are DONE
                Arrays.fill(dp[w][h], oo);

                // we can always give you 0 for ZERO cost
                dp[w][h][0] = 0;
                for (int k = 0; k <= 50; k++) {
                    if (w * h == k) {
                        // Base cases
                        dp[w][h][k] = 0;
                    }
                }
            }
        }
        for (int k = 0; k <= 50; k++) {
            for (int w = 0; w <= 30; w++) {
                for (int h = 0; h <= 30; h++) {
                    // From dp[w][h][k], we want to split in any way along the
                    // horizontal: dp[x][h][k] + dp[w - x][h][k] + h * h
                    // Or, along the vertical: dp[w][x][k] + dp[w][h - x][k] + w * w
                    for (int w2 = 1; w2 < w; w2++) {
                        for (int k2 = 0; k2 <= k; k2++) {
                            // Once we've split down a certain w, we can ask each side to give
                            // some amount of k. So we split here from asking none to asking for all

                            // In total, we will have iterated over all possible combinations, since
                            // for each size split on the left side for example, we are asking it
                            // to give all possible amounts from 0 to k. So, this doesn't double count!
                            int subAnswer = dp[w2][h][k2] + dp[w - w2][h][k - k2] + h * h; // cost = h * h !!
                            dp[w][h][k] = Math.min(dp[w][h][k], subAnswer);
                        }
                    }

                    for (int h2 = 1; h2 < h; h2++) {
                        for (int k2 = 0; k2 <= k; k2++) {
                            // Once we've split down a certain h, we can ask each side to give
                            // some amount of k. So we split here from asking none to asking for all
                            int subAnswer = dp[w][h2][k2] + dp[w][h - h2][k - k2] + w * w; // cost = w * w !!
                            dp[w][h][k] = Math.min(dp[w][h][k], subAnswer);
                        }
                    }
                }
            }
        }

//        for (int w = 0; w <= 30; w++) {
//            for (int h = 0; h <= 30; h++) {
//                System.out.print(dp[w][h][1] + " ");
//            }
//            System.out.println();
//        }
        while (T-->0) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            int k = sc.nextInt();
            out.println(dp[n][m][k]);
        }

        out.close();
    }

    static class FastScanner {
        public int BS = 1<<16;
        public char NC = (char)0;
        byte[] buf = new byte[BS];
        int bId = 0, size = 0;
        char c = NC;
        double cnt = 1;
        BufferedInputStream in;

        public FastScanner() {
            in = new BufferedInputStream(System.in, BS);
        }

        public FastScanner(String s) {
            try {
                in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
            }
            catch (Exception e) {
                in = new BufferedInputStream(System.in, BS);
            }
        }

        private char getChar(){
            while(bId==size) {
                try {
                    size = in.read(buf);
                }catch(Exception e) {
                    return NC;
                }
                if(size==-1)return NC;
                bId=0;
            }
            return (char)buf[bId++];
        }

        public int nextInt() {
            return (int)nextLong();
        }

        public int[] nextInts(int N) {
            int[] res = new int[N];
            for (int i = 0; i < N; i++) {
                res[i] = (int) nextLong();
            }
            return res;
        }

        public long[] nextLongs(int N) {
            long[] res = new long[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextLong();
            }
            return res;
        }

        public long nextLong() {
            cnt=1;
            boolean neg = false;
            if(c==NC)c=getChar();
            for(;(c<'0' || c>'9'); c = getChar()) {
                if(c=='-')neg=true;
            }
            long res = 0;
            for(; c>='0' && c <='9'; c=getChar()) {
                res = (res<<3)+(res<<1)+c-'0';
                cnt*=10;
            }
            return neg?-res:res;
        }

        public double nextDouble() {
            double cur = nextLong();
            return c!='.' ? cur:cur+nextLong()/cnt;
        }

        public String next() {
            StringBuilder res = new StringBuilder();
            while(c<=32)c=getChar();
            while(c>32) {
                res.append(c);
                c=getChar();
            }
            return res.toString();
        }

        public String nextLine() {
            StringBuilder res = new StringBuilder();
            while(c<=32)c=getChar();
            while(c!='\n') {
                res.append(c);
                c=getChar();
            }
            return res.toString();
        }

        public boolean hasNext() {
            if(c>32)return true;
            while(true) {
                c=getChar();
                if(c==NC)return false;
                else if(c>32)return true;
            }
        }
    }
}