We are given an integer of 32 bits, an integer of 16 bits, two characters of 8 bits, and would like to assemble them into an integer of 64 bits according to a pattern string. The three integers mentioned are all unsigned so their values are nonnegative. The pattern string consists of an ‘L’, an ‘S’ , and two ‘C’s for one 32-bit unsigned integer, one 16-bit unsigned integer, and two characters respectively. Now we want to assemble these four values into a 64-bit unsigned integer according to this pattern string, so that the four values appear in the 64 bit integer from the most significant bit (on the left) to the least significant bit (on the right), according to the order they appear in the pattern string.
Let us try an example. If the pattern string is "LSCC", then we need to pack the four values into a 64-bit unsigned integer in the order that the 32-bit unsigned integer appears in the most significant bits (on the most left), then the 16-bit unsigned integer, then the first character, and finally the second character (on the most right). Note that the first occurrence of ‘C’ represent the first character, and the second 'C' is the second character. Please refer to the following figure for an illustration.
In addition, we want to do the reverse. That is, we will have a 64-bit unsigned integer and a pattern string, and we need to retrieve the 32-bit unsigned integer, the 16-bit unsigned integer, and two characters according to the pattern string.
Write a program for these two types of conversions. If you are given task type 0 then you convert a 32-bit unsigned integer, a 16-bit unsigned integer, and two characters into a 64-bit unsigned integer. If you are given task type 1 then you do the reverse.
The format specifiers for unsigned long long int (64 bit), unsigned int (32 bit), and unsigned short (16 bit) are as follows.
Also the two characters can be read by
The first line of the input has a task type. The following are several cases you need to process all of them until EOF. If task type is 0, each line consists of a pattern string, a 32-bit unsigned integer, a 16-bit unsigned integer, and a string of two characters. If task type is 1, each line consists of a pattern string and a 64-bit unsigned integer.
If task type is 0, output the 64-bit unsigned integer for each case. If task type is 1, output a 32-bit unsigned integer, a 16-bit unsigned integer, and a string of two characters.
- 10 points: task type is 0 and the pattern string is ‘LSCC’
- 40 points: task type is 0 and the pattern string can be any combination.
- 10 points: task type is 1 and the patterns string is ‘LSCC’
- 40 points: task type is 1 and the pattern string can be any combination.
Sample Input 1
LSCC 3608568949 21353 Fp
LSCC 686398347 65535 pF
Sample Output 1
Sample Input 2
CCSL 1522576207 32431 n8
SCCL 1234567890 8763 kk
Sample Output 2
Sample Input 3
Sample Output 3
3608568949 21353 Fp
686398347 65535 pF
Sample Input 4
Sample Output 4
1522576207 32431 n8
1234567890 8763 kk
Sample for subtask 1 ~ 4
Inside the testdata.