A synthetic biology lab is designing short RNA molecules over the alphabet {A, C, G, U}.
For this exercise, assume that the lab wants to discard every sequence that contains two consecutive guanines (GG), and wants to know how many candidate sequences of a given length are left.

For example, AGCG is allowed, while AGGC is not.


Problem Description

Given an integer n, compute the number of RNA sequences of length n over {A, C, G, U} that do not contain GG as a substring.

For example, if n = 2 there are 4 × 4 = 16 possible sequences and only one of them (GG) is forbidden:

AA AC AG AU
CA CC CG CU
GA GC    GU
UA UC UG UU

→ 15 valid sequences.


Function Description

Implement the following function:

def countNoGG(n: int) -> int:
    # Write your code here

Parameters

  • n: length of the sequence (n ≥ 0)

Returns

  • int: number of sequences of length n that do not contain GG

Example

Input

2

Output

15

💡 Hint

Listing all the 4^n sequences is far too slow. Instead, look at the last nucleotide of a valid sequence of length n:

  • it is A, C or U (3 choices): the first n-1 nucleotides can be any valid sequence of length n-1;
  • it is G: then the nucleotide before it must be A, C or U (3 choices), and the first n-2 nucleotides can be any valid sequence of length n-2.

with count(0) = 1 (the empty sequence) and count(1) = 4.

Then fill a 1D table, so that every value is computed only once:

012345
141557??

What is the time and space complexity of your solution? How does it compare with generating all the sequences?


Test

Input2

10

Output2

641520