Annie just learned how to play competitive chess and is learning about the ELO-MMR system. She doesn't really know how it works, but she does know that the higher ELO a player is, the more skilled the player.
Annie has potential opponents (with funky usernames) that she wants to know the ELO of. She will use their usernames to guess their ELOs. Each username will only have upper or lowercase latin characters (letters from A-Z
or a-z
) and arabic numerals (digits from 0-9
).
She will guess a player's ELO with the following steps:
The player's ELO is initially minus the number of characters in the username, multiplied by .
If the username has no numerical digits, the player's ELO is multiplied by .
Every numerical digit between two letters will increase the ELO of the player by the value of that digit multiplied by .
- For example, the username
b2w3n
will have its initial ELO increased by and again by .
- For example, the username
Every trailing numerical digit (after the last letter or all digits if there are no letters) will decrease the ELO of the player by the value of that digit multiplied by .
- For example, the username
a12
will have its initial ELO decreased by and again by .
- For example, the username
Every two identical consecutive characters will decrease the ELO of the player by .
- For example, having
zz
in the username will decrease the ELO of the player by , and havingAAA
in the username will decrease the ELO of the player by .
- For example, having
Given opponents, can you help Annie guess all their ELOs? Note that ELOs may be negative, that's fine!
Constraints
, where denotes the number of characters in an opponent's username.
Input Specification
The first line will contain .
The next lines will contain a valid username according to the above specifications.
Output Specification
For each username, output the guessed ELO on a new line.
Sample Input
4
mar5flaa
Pingu
NOTanieni6002
aazzaazzron
Sample Output
1145
2500
765
1880
Explanation for Sample Output
The first username, mar5flaa
, has characters for an initial ELO of . Because there is a 5
in between characters r
and f
, the ELO is increased by . Finally, because there are two identical consecutive characters (aa
), the ELO is decreased by for a total of .
The second username, Pingu
, has characters for an initial ELO of . Since there are no numerical digits in the username, however, the ELO is multiplied by to equal .
The third username, NOTanieni6002
, has characters for an initial ELO of . Because there is a trailing 6002
, the ELO is decreased by , (twice), and . The consecutive 0
s also decrease the ELO by , for a total of .
Comments