#K76592. Largest Possible Integer and Sum

    ID: 34676 Type: Default 1000ms 256MiB

Largest Possible Integer and Sum

Largest Possible Integer and Sum

You are given a task to transform integers into the largest possible integer by reordering their digits in descending order. For example, given the integer \(132\), by rearranging its digits, the largest possible integer is \(321\).

Besides processing a single integer, you will handle multiple test cases. Each test case consists of a list of integers. Your task is to compute, for each test case, the sum of the largest possible integers obtained from each given integer.

For instance, in a test case with the integers \(132\), \(45\), and \(87\), the largest integers generated are \(321\), \(54\), and \(87\) respectively, and their sum is \(462\). Output the result for each test case on a separate line.

inputFormat

The first line contains an integer \(T\), representing the number of test cases. Each test case follows with two lines:

  1. The first line contains an integer \(N\), the number of integers in the test case.
  2. The second line contains \(N\) space-separated integers.

outputFormat

For each test case, output a single line with the sum of the largest possible integers (after rearranging the digits of each number in descending order).

## sample
2
3
132 45 87
2
970 3241
462

5291

</p>