// 置換の積を計算 fun prod(p: Array, q: Array): Array { val n = p.size val r = Array(n) { 0 } for (i in 0 until n) { r[i] = q[p[i]] } return r } fun makeReflectionLeft(n: Int, p: Int): Array { val x = Array(n) { it } for (i in 0 until p) { x[p - 1 - i] = i } return x } fun makeReflectionRight(n: Int, q: Int): Array { val x = Array(n) { it } for (i in n - q until n) { x[i] = 2 * n - q - i - 1 } return x } fun modpow(a: Int, e: Int, mod: Long): Long { if (e == 0) return 1 if (e == 1) return a % mod val b = modpow(a, e / 2, mod).let { it * it } % mod return if (e % 2 == 0) { b } else { a * b % mod } } fun main() { val (n, p, q) = readInts() if (p == 1 && q == 1) { println(1) } else if (p == 1 || q == 1) { println(2) } else { val x = makeReflectionLeft(n, p) val y = makeReflectionRight(n, q) val xy = prod(x, y) val uf = UnionFind(n) for (i in 0 until n) { uf.unite(i, xy[i]) } val set = mutableSetOf() for (i in 0 until n) { set.add(uf.find(i)) } val sizes = mutableSetOf() for (i in set) { sizes.add(uf.size(i)) } val minfac = Array(100005) { it } for (d in 2 until 100005) { if (minfac[d] != d) continue var i = 2 while (d * i < 100005) { minfac[d * i] = minOf(minfac[d * i], d) i++ } } val lcm = mutableMapOf() for (size in sizes) { val pf = mutableMapOf() var m = size while (m > 1) { val fac = minfac[m] pf[fac] = (pf[fac] ?: 0) + 1 m /= fac } for ((fac, e) in pf) { lcm[fac] = maxOf(lcm[fac] ?: 0, e) } } var ans = 2L val mod = 998244353L for ((fac, e) in lcm) { ans *= modpow(fac, e, mod) ans %= mod } println(ans) } } class UnionFind(n: Int) { private val rank = IntArray(n) { 0 } private val parent = IntArray(n) { -1 } fun find(x: Int): Int { if (parent[x] < 0) { return x } parent[x] = find(parent[x]) return parent[x] } fun unite(x: Int, y: Int) { val x1 = find(x) val y1 = find(y) if (x1 == y1) { return } if (rank[x1] < rank[y1]) { parent[y1] += parent[x1] parent[x1] = y1 } else { parent[x1] += parent[y1] parent[y1] = x1 if (rank[x1] == rank[y1]) { rank[x1]++ } } } fun same(x: Int, y: Int): Boolean { return find(x) == find(y) } fun size(x: Int): Int { return -parent[find(x)] } } fun readInts() = readln().split(" ").map { it.toInt() }