URJC2_D - Keyboard Writing

no tags 

Writing at the keyboard can be as easy as riding a bike or as difficult as making a pie (bet you can’t make a pie, can you?).

We want to estimate the time that a person will take to write a line, for simplicity, the line will contain only lowercase letters.

The person who will take the test will know for sure where some keys are, if they are reading the text and they know beforehand where the key is, they will take on average 50ms to type the letter, else, they will take 150ms to identify the key and then type it. After that, the key will be learnt and if the same letter appears they will no longer need to identify the key, hence, they will just press it and take 50ms.

Input

The first line contains an integer T, which specifies the number of test cases. Then, will follow the descriptions of T test cases.

Each test case will contain two lines, the first line A will contain up to 26 lowercase letters denoting the letters the person knows. The second line B will contain a string of lower case characters that the person needs to transcribe.

Output

For each input case you must print the number of milliseconds the person needs to write down the second line of each test case.

Example

Input:
2
urjc
urjccontesttwo
abcdefghijklmnopqrstuvwxyz
thequickbrownfoxjumpsoverthelazydog

Output:
1300
1750

Constraints

  • 1 ≤ |A| ≤ 26
  • 1 ≤ |B| ≤ 100,000

hide comments
harsh_03: 2017-12-12 09:39:35

@david_8k tested for boundary conditions also ... WA still

Last edit: 2017-12-13 20:50:47

Added by:david_8k
Date:2017-03-29
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All
Resource:Own Problem