#include int ri() { int n; scanf("%d", &n); return n; } int main() { int n = ri(); int p = ri(); int q = ri(); std::vector next(2 * n); for (int i = 0; i < 2 * n; i++) { int cur_next = i % n; if (i < n && cur_next < p) cur_next = p - 1 - cur_next; if (i >= n && cur_next >= n - q) cur_next = n - 1 - (q - 1 - (n - 1 - cur_next)); if (i < n) cur_next += n; next[i] = cur_next; } std::map factors; std::vector len(2 * n, -1); bool half = true; for (int i = 0; i < 2 * n; i++) if (len[i] == -1) { int cur = i; std::vector path; do { path.push_back(cur); cur = next[cur]; } while (cur != i); for (auto i : path) len[i] = path.size(); if (len[i] % 2 == 0) { int h = path.size() / 2; for (int i = 0; i < h; i++) if (path[i] % n != path[i + h] % n) half = false; } // std::cerr << len[i] << std::endl; int m = path.size(); for (int i = 2; i * i <= m; i++) { int cnt = 0; while (m % i == 0) cnt++, m /= i; factors[i] = std::max(factors[i], cnt); } if (m > 1) factors[m] = std::max(factors[m], 1); } // std::cerr << half << std::endl; int res = 1; for (auto i : factors) { for (int j = 0; j < i.second; j++) res = (int64_t) res * i.first % 998244353; } if (half) { if (res & 1) res = (res + 998244353) / 2; else res /= 2; } if (!factors[2]) { res++; if (res & 1) res = (res + 998244353) / 2; else res /= 2; } std::cout << res << std::endl; return 0; }