#K73087. Chef's Energy Expenditure Problem

    ID: 33897 Type: Default 1000ms 256MiB

Chef's Energy Expenditure Problem

Chef's Energy Expenditure Problem

Chef is on a run along a course consisting of several checkpoints. At each checkpoint, three integers are provided: the distance D (which is not used in the calculation), the speed S, and the time T. The energy expenditure at the i-th checkpoint is calculated using the formula:

$$E_i = S_i^2 \times T_i$$

The total energy expenditure for a test case is the sum of the energy expenditures at all checkpoints:

$$Total\ Energy = \sum_{i=1}^{N} \left(S_i^2 \times T_i\right)$$

Your task is to compute the total energy expenditure for each test case.

inputFormat

The input begins with an integer T representing the number of test cases. Each test case consists of two lines:

  1. The first line contains an integer N, the number of checkpoints.
  2. The second line contains 3N space-separated integers. These integers represent the values D, S, and T for each checkpoint, in that order. Note that the distance D is provided but not used in the calculation.

All input is provided via standard input (stdin).

outputFormat

For each test case, print a single integer on a new line representing the total energy expenditure computed using the formula:

$$Total\ Energy = \sum_{i=1}^{N} \left(S_i^2 \times T_i\right)$$

The output should be printed to standard output (stdout).

## sample
1
1
0 2 3
12

</p>