# 50134. 64, 32, 16, and 8

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

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.

## Notes

The format specifiers for unsigned long long int (64 bit), unsigned int (32 bit), and unsigned short (16 bit) are as follows.

unsigned long long int ULLI;scanf("%llu", &ULLI);printf("%llu", ULLI);unsigned int UI;scanf("%u", &UI);printf("%u", UI);unsigned short US;scanf("%hu", &US);printf("%hu", US);


Also the two characters can be read by scanf(“%s”, str);.

## Input Format

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.

## Output Format

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

0LSCC 3608568949 21353 FpLSCC 686398347 65535 pF


## Sample Output 1

154986856227155001442948058456688390214


## Sample Input 2

0CCSL 1522576207 32431 n8SCCL 1234567890 8763 kk


## Sample Output 2

79422372344748224792466683329455719122


## Sample Input 3

1LSCC 15498685622715500144LSCC 2948058456688390214


## Sample Output 3

3608568949 21353 Fp686398347 65535 pF


## Sample Input 4

1CCSL 7942237234474822479SCCL 2466683329455719122


## Sample Output 4

1522576207 32431 n81234567890 8763 kk


## Sample for subtask 1 ~ 4

Inside the testdata.