#C14542. Sum of Squares of Unique Values

    ID: 44203 Type: Default 1000ms 256MiB

Sum of Squares of Unique Values

Sum of Squares of Unique Values

You are given a set of keys, each associated with a list of integers. For each key, compute the sum of the squares of the unique integers present in its list. The square of a number is expressed as x2x^2.

The input begins with an integer KK, representing the number of keys. Following this, for each key, there are three inputs: a string key, an integer NN denoting the number of integers for that key, and a line of NN space-separated integers. If N=0N=0, the corresponding line for integers will be empty.

Output each key and its computed sum in the format key: result on a separate line, preserving the order of the keys as given in the input.

inputFormat

The first line contains an integer KK, the number of keys. For each key, the following three lines are provided:
1. A string representing the key.
2. An integer NN indicating the number of integers in the list.
3. A line with NN space-separated integers (this line will be empty if NN is 0).

outputFormat

For each key, print a line in the format key: result, where result is the sum of the squares of all unique integers associated with that key.## sample

3
a
4
1 2 2 4
b
3
2 3 3
c
3
4 4 4
a: 21

b: 13 c: 16

</p>