// Arup Guha
// 12/10/2019
// Solution to 2019 UCF HS Online D2 Problem: Exponential Escape Escapade

import java.util.*;

public class escape {

	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		int nC = stdin.nextInt();
		
		// Process each case.
		for (int loop=1; loop<=nC; loop++) {
			
			// Glad we don't have to worry about overflow!
			int a = stdin.nextInt();
			int b = stdin.nextInt();
			int c = stdin.nextInt();
			System.out.println(a*a*a+b*b*b+c*c*c);
		}
	}
}