The Monk and Kundan
Tag(s):

Problem
Editorial
Analytics

Kundan being a good friend of Monk, lets the Monk know that he has a following string Initial which consists of the following letters in the mentioned order: "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ".

He also has various lists of strings, and now he wants the Monk to compute the Hash value of each list of strings.
Here's the following algorithm used by the Monk to do it.
So, the Hash is the summation of all the character values in the input:
(currentIndex + (position of the character In the string initial) ). And then this hash is multiplied by the Number of strings in the list.

Let's assume that the list of strings is: ["aA1", "b"]. So, our answer would be:
a: 0 + 0 = 0.
A: 1 + $36$ = $37$.
1: 2 + $26$ = $28$.
b: 0 + 1 = 1.

So, 2 * (0 + 1 + $37$ + $28$) = 2 * ($66$) = $132$.

Input format:
The first line contains an integer T, denoting the number of test cases. For every test case, on a single line, there will be N number of strings all of them separated by a space, denoting all the strings of that particular list of strings.

Output format:
Print the required hash for each of the mentioned list of strings.

Constraints:
1 ≤ Test Cases ≤ $50$
1 ≤ Length of a string ≤ $30$
1 ≤ Number of strings in a list ≤ $20$

Note:
All the characters in the input will be valid, that is, will be part of the string Initial.

SAMPLE INPUT
3
aA1 b
a b c d
aa BB cc DD

SAMPLE OUTPUT
132
24
640

Explanation

Refer to the statement again for the sample explanation.

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), TypeScript, Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, Visual Basic

## CODE EDITOR

Initializing Code Editor...

## This Problem was Asked in

Challenge Name

Code Monk (Hashing)

OTHER PROBLEMS OF THIS CHALLENGE
• Data Structures > Hash Tables
• Data Structures > Hash Tables
• Algorithms > String Algorithms
• Algorithms > String Algorithms