#agc040c. [agc040_c]Neither AB nor BA
[agc040_c]Neither AB nor BA
Problem Statement
Given is a positive even number .
Find the number of strings of length consisting of A
, B
, and C
that satisfy the following condition:
- can be converted to the empty string by repeating the following operation:
- Choose two consecutive characters in and erase them. However, choosing
AB
orBA
is not allowed.
- Choose two consecutive characters in and erase them. However, choosing
For example, ABBC
satisfies the condition for , because we can convert it as follows: ABBC
→ (erase BB
) → AC
→ (erase AC
) → (empty)
.
The answer can be enormous, so compute the count modulo .
Constraints
- is an even number.
Input
Input is given from Standard Input in the following format:
Output
Print the number of strings that satisfy the conditions, modulo .
Sample Input 1
2
Sample Output 1
7
Except AB
and BA
, all possible strings satisfy the conditions.
Sample Input 2
10
Sample Output 2
50007
Sample Input 3
1000000
Sample Output 3
210055358