#C2128. Counting Valid Bead Sequences

    ID: 45410 Type: Default 1000ms 256MiB

Counting Valid Bead Sequences

Counting Valid Bead Sequences

You are given an integer L representing the length of a bead sequence where each bead can be one of three colors: R, B, or G. A sequence is considered valid if no two adjacent beads are of the same color.

Your task is to compute the number of valid sequences of length L. It can be mathematically proven that the answer is given by the formula:

\(3 \times 2^{L-1}\)

For example, when L = 1, there are 3 valid sequences (one for each color), and when L = 3, the answer is \(3 \times 2^{2} = 12\).

You need to implement a program that reads several test cases from standard input, each representing a value for L, and outputs the corresponding number of valid sequences to standard output.

inputFormat

The first line contains an integer T, the number of test cases. Each of the following T lines contains one integer L (1 ≤ L) representing the length of the bead sequence.

Example:

3
1
2
3

outputFormat

For each test case, output a single line with the number of valid sequences.

Example:

3
6
12
## sample
1
1
3

</p>