Under construction

Still being built. Things may change

Drop The Byte!

Interview

Time limit1sMemory limit256 MB

Summary
Given a hex string and a sequence of type sizes (char 2 digits, int 8, long_long 16), split the string and print each piece as a decimal value.
Level

Medium5 of 10

Topics
Implementation, String, Math, Simulation
Solved
No attempts yet

Statement

Jebeom is preparing for HCPC and studying hexadecimal numbers hard. He studied them so hard that he started writing every number in hexadecimal, and he has now come up with the following cipher.

"Suppose I write some number of hexadecimal digits with no spaces and tell you only which types they have in order. Could you turn all of them back into their original decimal values?"

Here a type means char, int, long_long, and so on, which are 1 byte, 4 bytes, and 8 bytes respectively. Also, since 1 byte is 8 bits, representing 1 byte in hexadecimal takes 2 digits, because one hexadecimal digit represents 4 binary digits.

Jebeom decided to call this cipher the 'Jebeom-style cipher'. He gave it to several people to see who could decrypt it. You are one of them. Decrypt Jebeom's cipher!

Input

The first line gives Jebeom's cipher in hexadecimal form. The cipher consists of 0~9 and a~f, where a~f mean 10~15. The length of the cipher is between 2 and 106 inclusive.

The second line gives N, the number of values that make up the cipher. (1 ≤ N ≤ 500,000)

The third line gives the types of the N values that make up the cipher, separated by spaces. Each type is one of "char", "int", "long_long".

Output

Print the values that make up Jebeom's cipher converted to decimal. Only inputs for which the hexadecimal values convert to non-negative decimals are given.

Examples2

  1. Example 1

    Input
    010000001f
    2
    char int
    
    Expected output
    1 31
    
  2. Example 2

    Input
    0000020a7f0000000007000a00
    3
    int char long_long
    
    Expected output
    522 127 117443072