1034: Count Sequences

Memory Limit:1024 MB Time Limit:4.000 S
Judge Style:Text Compare Creator:
Submit:20 Solved:7

Description

Find the number of sequences of integers with lns="http://www.w3.org/1998/Math/MathML"> terms, lns="http://www.w3.org/1998/Math/MathML">=(1,2,,), that satisfy the following conditions, modulo lns="http://www.w3.org/1998/Math/MathML">998244353.

  • lns="http://www.w3.org/1998/Math/MathML">012.
  • For each lns="http://www.w3.org/1998/Math/MathML">=1,2,,1, the remainder when lns="http://www.w3.org/1998/Math/MathML"> is divided by lns="http://www.w3.org/1998/Math/MathML">3 is different from the remainder when lns="http://www.w3.org/1998/Math/MathML">+1 is divided by lns="http://www.w3.org/1998/Math/MathML">3

Input

The input is given from Standard Input in the following format:

 lns="http://www.w3.org/1998/Math/MathML">

  • lns="http://www.w3.org/1998/Math/MathML">1107
  • All values in the input are integers.

lns="http://www.w3.org/1998/Math/MathML">

lns="http://www.w3.org/1998/Math/MathML">

Output

Print the answer.

Sample Input Copy

3 4

Sample Output Copy

8

HINT

Here are the eight sequences that satisfy the conditions.

  • lns="http://www.w3.org/1998/Math/MathML">(0,1,2)
  • lns="http://www.w3.org/1998/Math/MathML">(0,1,3)
  • lns="http://www.w3.org/1998/Math/MathML">(0,2,3)
  • lns="http://www.w3.org/1998/Math/MathML">(0,2,4)
  • lns="http://www.w3.org/1998/Math/MathML">(1,2,3)
  • lns="http://www.w3.org/1998/Math/MathML">(1,2,4)
  • lns="http://www.w3.org/1998/Math/MathML">(1,3,4)
  • lns="http://www.w3.org/1998/Math/MathML">(2,3,4)