Unable to solve all the testcases of this program considering all different test case.s

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		for(int i=0; i<t; i++){
		    int maxT = sc.nextInt();
		    int maxN = sc.nextInt();
		    int sumN = sc.nextInt();
		    int possibleT = sumN/maxN;
		    int possibleTT = sumN%maxN;
		    int maxIterations = 0;
		    
		    if(possibleT>maxT){
		        for(int j=0; j<maxT; j++){
		            maxIterations = maxIterations + maxN*maxN;
		        }
		        System.out.println(maxIterations+(possibleTT*possibleTT));
		    }
		    else{
		        for(int k=0; k<possibleT; k++){
		            maxIterations = maxIterations + maxN*maxN;
		        }
		        System.out.println(maxIterations+(possibleTT*possibleTT));
		    }
		}
	}
}