#P5392. Counting Independent Sets in a Cylindrical Grid Graph

    ID: 18624 Type: Default 1000ms 256MiB

Counting Independent Sets in a Cylindrical Grid Graph

Counting Independent Sets in a Cylindrical Grid Graph

Cirno defined a graph called the circular cylindrical network \(G(L, x)\). The graph \(G(L, x)\) consists of \(L \times x\) nodes. Each node is represented by an integer pair \((a, b)\) where \(1 \le a \le L\) and \(1 \le b \le x\).

There are three types of edges:

  1. For every \(i \in \{2,3,\ldots,L\}\) and every \(j \in \{1,2,\ldots,x\}\), there is an edge between \((i, j)\) and \((i-1, j)\).
  2. For every \(i \in \{1,2,\ldots,L\}\) and every \(j \in \{1,2,\ldots,x-1\}\), there is an edge between \((i, j)\) and \((i, j+1)\).
  3. For every \(i \in \{1,2,\ldots,L\}\), there is an edge between \((i, x)\) and \((i, 1)\).

An independent set of a graph is a set of nodes such that no two nodes in the set are adjacent. In this problem, you are asked to determine the number of independent sets in the graph \(G(L, x)\) modulo \(998244353\).

inputFormat

The input consists of a single line containing two integers \(L\) and \(x\) separated by a space.

outputFormat

Output the number of independent sets in \(G(L, x)\) modulo \(998244353\).

sample

1 3
4

</p>