import java.io.PrintWriter import java.util.* import kotlin.math.* // 置換の積を計算 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 PrintWriter.solve() { val n = nextInt() val p = nextInt() val q = nextInt() 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] = min(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] = max(lcm[fac] ?: 0, e) } } var ans = ModInt(2) for ((fac, e) in lcm) { ans *= ModInt(fac).pow(e.toLong()) } println(ans) } } // region ModInt class ModInt(x: Long) { companion object { const val MOD = 998244353L //const val MOD = 1000000007L } constructor(y: Int) : this(y.toLong()) val x = (x % MOD + MOD) % MOD operator fun plus(other: ModInt): ModInt { return ModInt(x + other.x) } operator fun minus(other: ModInt): ModInt { return ModInt(x - other.x) } operator fun times(other: ModInt): ModInt { return ModInt(x * other.x) } operator fun div(other: ModInt): ModInt { return this * other.inv() } fun pow(exp: Long): ModInt { if (exp == 0L) return ModInt(1L) var a = pow(exp shr 1) a *= a if (exp and 1L == 0L) return a return this * a } fun inv(): ModInt { return this.pow(MOD - 2) } override fun equals(other: Any?): Boolean { if (this === other) return true if (javaClass != other?.javaClass) return false other as ModInt if (x != other.x) return false return true } override fun hashCode(): Int { return x.hashCode() } override fun toString(): String { return "$x" } } class ModIntArray(n: Int) { private val a = LongArray(n) { 0L } constructor(n: Int, init: (Int) -> ModInt) : this(n) { for (i in 0 until n) { a[i] = init(i).x } } operator fun set(i: Int, x: ModInt) { a[i] = x.x } operator fun get(i: Int): ModInt { return ModInt(a[i]) } fun joinToString(s: String): String { return a.joinToString(s) } } fun Long.toModInt(): ModInt { return ModInt(this) } fun Int.toModInt(): ModInt { return ModInt(this) } fun binomSimple(n: Long, k: Long): ModInt { var numer = ModInt(1) var denom = ModInt(1) for (i in 0 until k) { numer *= ModInt(n - i) denom *= ModInt(k - i) } return numer / denom } // endregion 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 main() { Thread(null, { val writer = PrintWriter(System.out, false) writer.solve() writer.flush() }, "solve", abs(1L.shl(26))) .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); kotlin.system.exitProcess(1) } } .apply { start() }.join() } // region Scanner private var st = StringTokenizer("") private val br = System.`in`.bufferedReader() fun next(): String { while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) return st.nextToken() } fun nextInt() = next().toInt() fun nextLong() = next().toLong() fun nextLine() = br.readLine() fun nextDouble() = next().toDouble() // endregion