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:
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class a {
	public static int k;

	public static class node implements Comparable<node> {
		int x;
		int y;
		int pos;

		node(int x, int y, int pos) {
			this.x = x;
			this.y = y;
			this.pos = pos;
		}

		@Override
		public int compareTo(node o) {
			if (k == 0) {
				if (o.y < y)
					return 1;
				else if (o.y > y)
					return -1;
				else if (o.x < x)
					return 1;
				else if (o.x > x)
					return -1;

			} else if (k == 1) {
				if (o.x < x)
					return 1;
				else if (o.x > x)
					return -1;
				else if (o.y < y)
					return 1;
				else if (o.y > y)
					return -1;
			} else {
				if (sqrt(o) > Math.sqrt((double) x * (double) x + (double) y
						* (double) y))
					return 1;
				else if (sqrt(o) < Math.sqrt((double) x * (double) x
						+ (double) y * (double) y))
					return -1;
			}
			return 0;
		}

	}

	public static class point {
		int x;
		int y;

		point(int x, int val) {
			this.x = x;
			this.y = val;
		}

	}

	public static BigInteger gcd(BigInteger a, BigInteger b) {
		if (b.equals(BigInteger.ZERO))
			return a;
		return gcd(b, a.mod(b));
	}

	public static long gcd1(long a, long b) {
		if (b == 0)
			return a;
		return gcd1(b, a % b);
	}

	public static ArrayList<Integer> prime;

	public static void sieve(int n) {
		boolean vis[] = new boolean[n + 5];
		vis[1] = true;
		vis[0] = true;
		for (int i = 2; i <= n; i++) {
			if (!vis[i]) {
				prime.add(i);
				for (long j = (long) i * (long) i; j <= n; j += i) {
					vis[(int) j] = true;
				}
			}
		}
	}

	public static int tree[][];
	public static boolean end[][];
	public static int counter;

	public static void trie(String a) {
		int st = 0;

		for (int i = 0; i < a.length(); i++) {
			if (tree[a.charAt(i) - 'a'][st] == 0) {
				tree[a.charAt(i) - 'a'][st] = counter++;
			}

			st = tree[a.charAt(i) - 'a'][st];
		}
		end[a.charAt(a.length() - 1) - 'a'][st] = true;

	}

	public static int seg[][];

	public static int get(int s, int e, int p, int from, int to, int seg[]) {
		if (s >= from && e <= to)
			return seg[p];
		if (s > to || e < from)
			return 0;
		int mid = (s + e) / 2;
		int one = get(s, mid, p * 2, from, to, seg);
		int two = get(mid + 1, e, p * 2 + 1, from, to, seg);
		return Math.max(one, two);
	}

	public static long comp(int n, int r) {
		long ans = 1;
		r = Math.min(r, n - r);
		for (int i = 1; i <= r; i++) {
			ans = ans * ((long) n - (long) i + 1L) / (long) i;
		}
		return ans;
	}

	public static ArrayList<Integer> arr[];
	public static boolean vis[];
	public static Stack<Integer> S;

	public static void bfs(int node) {
		for (int i = 0; i < arr[node].size(); i++) {
			int k = arr[node].get(i);
			if (vis[k] == false) {
				vis[k] = true;
				S.push(k);
				bfs(k);
			}
		}
		S.push(node);
	}

	public static void dfs(int node) {

		for (int i = 0; i < arr[node].size(); i++) {
			int k = arr[node].get(i);
			if (vis[k] == false) {
				vis[k] = true;
				dfs(k);
			}
		}
	}

	public static boolean chPrime(int r) {

		for (int i = 2; i * i <= r; i++) {
			if (r % i == 0)
				return false;
		}
		return true;
	}

	public static int len(long ai) {
		String temp = "" + ai;

		return temp.length();
	}

	public static int f_digit(long ai) {
		String temp = "" + ai;

		return (temp.charAt(0) - '0');

	}

	public static double cross(node a, node b) {

		return a.x * b.y - b.x * a.y;
	}

	public static double dot(node a, node b) {

		return a.x * b.x + a.y * b.y;
	}

	public static double sqrt(node a) {
		double e = Math.sqrt((double) a.x * (double) a.x + (double) a.y
				* (double) a.y);
		return e;
	}

	public static double theta(node a, node b) {

		// double theta = Math.atan2((double) Math.abs(cross(a, b)),
		// (double) dot(a, b));

		double theta = (double) Math.acos((double) dot(a, b)
				/ ((sqrt(a)) * sqrt(b)));
		return theta;
	}

	public static long mod = (long) Math.pow(10, 9) + 7;

	public static long dp[][][];

	public static long solve(int n, int m, int k) {

		if (n * m == k)
			return 0;

		if (k == 0)
			return 0;

		if (dp[n][m][k] != -1)
			return dp[n][m][k];

		long a = 1 << 60L;
		for (int i = 1; i <= n / 2; i++) {
			int n2 = i;
			int n3 = n - i;
			//System.out.println(n2 + " " + m + " " + k);
			if (n2 * m <= k && n3 * m <= k) {
				a = Math.min(a, solve(n2, m, k - n3 * m) + m * m);
			} else if (n2 * m > k)
				a = Math.min(a, solve(n2, m, k) + m * m);
			else if (n2 * m <= k)
				a = Math.min(
						a,
						Math.min(solve(n3, m, k) + m * m,
								solve(n3, m, k - n2 * m) + m * m));
		}

		for (int i = 1; i <= m / 2; i++) {

			int m2 = i;
			int m3 = m - i;

			// System.out.println(k - m2 * n + " " + n + " " + m2 + " " + n *
			// n);

			if (m2 * n <= k && m3 * n <= k) {
				a = Math.min(a, solve(n, m2, k - m3 * n) + n * n);
			} else if (m2 * n > k)
				a = Math.min(a, solve(n, m2, k) + n * n);
			else if (n * m2 <= k)
				a = Math.min(
						a,
						Math.min(solve(n, m3, k) + n * n,
								solve(n, m3, k - m2 * n) + n * n));
		}
		// System.out.println(a);
		return dp[n][m][k] = a;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		// BufferedReader in = new BufferedReader(new FileReader("cubes.in"));
		// System.out.println(-70 % 3);
		StringBuilder qq = new StringBuilder();
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

		int t = Integer.parseInt(in.readLine());
		dp = new long[31][31][51];
		for (int i = 0; i < 31; i++) {
			for (int j = 0; j < 31; j++) {
				Arrays.fill(dp[i][j], -1);
			}
		}
		while (t-- > 0) {

			String y[] = in.readLine().split(" ");
			int n = Integer.parseInt(y[0]);
			int m = Integer.parseInt(y[1]);
			int k = Integer.parseInt(y[2]);

			

			out.println(solve(n, m, k));

		}
		out.close();

	}
}