50059. Binary Representation

I'm a slow walker, but I never walk backwards.

Task Description

Given $N$ 32-bit non-negative integers and a string $S$ consists of $32$ characters, represent the integers using characters in $S$.

A 32-bit integer has 32 bits, so after we concatenate $N$ of them, we will get a bit string of length $32 \cdot N$. For example, if we have two integers $1094975540$ and $52$, then the binary representation of $1094975540$ is 01000001010001000000000000110100, and that of $52$ is 00000000000000000000000000110100. After concatenating them we will have 0100000101000100000000000011010000000000000000000000000000110100.

Your task is to form every five bits into a group, starting from the most significant bit and ignore the trailing bits (忽略最後不滿五個的 bits). We will have $\lfloor{\frac{N \cdot 32} {5}}\rfloor$ groups for a bit string of length $N \cdot 32$. Each group contains five bits, which is a binary representation of an integer in range $\lbrack 0, 2^5)$. For example, the bit string 0100000101000100000000000011010000000000000000000000000000110100 is splitted into $12$ groups as follows:

01000 00101 00010 00000 00000 01101 00000 00000 00000 00000 00000 00011 (0100)

Those groups represent $12$ integers $8$, $5$, $2$, $0$, $0$, $13$, $0$, $0$, $0$, $0$, $0$ and $3$ respectively.

We use those integers as indices and output the corresponding characters in the given string $S$. The index goes from $0$ to $31$. For example, given $S$ = AaBbCcDdEeFfGgHhIiJjKLMNOPQRSTUV, the group mentioned above should be represented by EcBAAgAAAAAb, which are the $8$-th, $5$-th, $2$-nd, $0$-th, $0$-th, $13$-th, $0$-th, $0$-th, $0$-th, $0$-th, $0$-th and $3$-rd character in $S$ respectively.

Input Format

Input contains one test case with three lines. The first line contains a string $S$ with exactly $32$ non-space characters. The second line contains an integer $N$, representing the number of 32-bit integers. The third line contains $N$ non-negative integers.

  • $1 \leq N \leq 20000$

Output Format

Output one line with $\lfloor{\frac{N \cdot 32} {5}}\rfloor$ characters, representing the decoded string.

Sample Input

AaBbCcDdEeFfGgHhIiJjKLMNOPQRSTUV
2
1094975540 52

Sample Output

EcBAAgAAAAAb

Discussion