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: C, C++, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala 2.11.8, Swift, 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
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.15642191469669342, "perplexity": 3499.9919052445457}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2017-17/segments/1492917125719.13/warc/CC-MAIN-20170423031205-00322-ip-10-145-167-34.ec2.internal.warc.gz"}