#if __has_include() #include #else #include #include #include #include #include #include #include #include #include #include #include #include #include #include #endif namespace vectorial { template bool chmin(T& x, const T& y) { return y >= x ? false : (x = y, true); } template bool chmax(T& x, const T& y) { return y <= x ? false : (x = y, true); } template constexpr int pow_m1(T n) { return -(n & 1) | 1; } template constexpr T fld(const T x, const T y) { T q = x / y, r = x % y; return q - ((x ^ y) < 0 and (r != 0)); } template constexpr T cld(const T x, const T y) { T q = x / y, r = x % y; return q + ((x ^ y) > 0 and (r != 0)); } } namespace vectorial::macro { #define IMPL_REPITER(cond) auto& begin() { return *this; } auto end() { return nullptr; } auto& operator*() { return _val; } auto& operator++() { return _val += _step, *this; } bool operator!=(std::nullptr_t) { return cond; } template == std::is_signed_v), std::nullptr_t> = nullptr> struct rep_impl { Int _val; const Int _end, _step; rep_impl(Int n) : rep_impl(0, n) {} rep_impl(IntL l, Int r, IntStep step = 1) : _val(l), _end(r), _step(step) {} IMPL_REPITER((_val < _end)) }; template == std::is_signed_v), std::nullptr_t> = nullptr> struct rrep_impl { Int _val; const Int _end, _step; rrep_impl(Int n) : rrep_impl(0, n) {} rrep_impl(IntL l, Int r) : _val(r - 1), _end(l), _step(-1) {} rrep_impl(IntL l, Int r, IntStep step) : _val(l + fld(r - l - 1, step) * step), _end(l), _step(-step) {} IMPL_REPITER((_val >= _end)) }; template struct repinf_impl { Int _val; const Int _step; repinf_impl(Int l, IntStep step = 1) : _val(l), _step(step) {} IMPL_REPITER((true)) }; #undef IMPL_REPITER } #ifndef VECTORIAL_INPUT_STREAM #define VECTORIAL_INPUT_STREAM #include #ifndef VECTORIAL_TYPE_TRITS #define VECTORIAL_TYPE_TRITS #include #include #include namespace vectorial { template using constraints_t = std::enable_if_t, std::nullptr_t>; template struct bitnum { static constexpr int value = 0; }; template struct bitnum>> { static constexpr int value = std::numeric_limits>::digits; }; template static constexpr int bitnum_v = bitnum::value; template struct is_nbit { static constexpr bool value = bitnum_v == n; }; template static constexpr bool is_nbit_v = is_nbit::value; template struct safely_multipliable { using type = T; }; template struct safely_multipliable, is_nbit>> { using type = long long; }; template struct safely_multipliable, is_nbit>> { using type = __int128_t; }; template struct safely_multipliable, is_nbit>> { using type = unsigned long long; }; template struct safely_multipliable, is_nbit>> { using type = __uint128_t; }; template using safely_multipliable_t = typename safely_multipliable::type; template struct rec_value_type { using type = T; }; template struct rec_value_type> { using type = typename rec_value_type::type; }; template using rec_value_type_t = typename rec_value_type::type; template class is_iterable { template static auto test(T_ e) -> decltype(e.begin(), e.end(), std::true_type{}); static std::false_type test(...); public: static constexpr bool value = decltype(test(std::declval()))::value; }; template static constexpr bool is_iterable_v = is_iterable::value; template class is_writable { template static auto test(T_ e) -> decltype(std::declval() << e, std::true_type{}); static std::false_type test(...); public: static constexpr bool value = decltype(test(std::declval()))::value; }; template static constexpr bool is_writable_v = is_writable::value; template class is_readable { template static auto test(T_ e) -> decltype(std::declval() >> e, std::true_type{}); static std::false_type test(...); public: static constexpr bool value = decltype(test(std::declval()))::value; }; template static constexpr bool is_readable_v = is_readable::value; } #endif namespace vectorial::io { template >, std::negation>>>, std::nullptr_t> = nullptr> struct InputStream { private: using istream_type = std::remove_reference_t; IStream is; struct { InputStream* is; template operator T() { T e; *is >> e; return e; } } _reader{ this }; public: template InputStream(IStream_ &&is) : is(std::move(is)) {} template InputStream(IStream_ &is) : is(is) {} template InputStream& operator>>(T& e) { if constexpr (vectorial::is_readable_v) is >> e; else _read(e); return *this; } auto read() { return _reader; } template void read(Head& head, Tail &...tails) { ((*this >> head) >> ... >> tails); } istream_type& get_stream() { return is; } private: static __uint128_t _stou128(const std::string& s) { __uint128_t ret = 0; for (char c : s) if ('0' <= c and c <= '9') ret = 10 * ret + c - '0'; return ret; } static __int128_t _stoi128(const std::string& s) { return (s[0] == '-' ? -1 : +1) * _stou128(s); } void _read(__uint128_t& v) { v = _stou128(std::string(_reader)); } void _read(__int128_t& v) { v = _stoi128(std::string(_reader)); } template void _read(std::pair& a) { *this >> a.first >> a.second; } template void _read(std::tuple& a) { if constexpr (N < sizeof...(Args)) *this >> std::get(a), _read(a); } template , std::nullptr_t> = nullptr> void _read(Iterable& a) { for (auto& e : a) *this >> e; } }; template InputStream(IStream &&) -> InputStream; template InputStream(IStream &) -> InputStream; InputStream cin{ std::cin }; auto read() { return cin.read(); } template void read(Head& head, Tail &...tails) { cin.read(head, tails...); } } namespace vectorial { using io::read; } #endif #ifndef VECTORIAL_OUTPUT_STREAM #define VECTORIAL_OUTPUT_STREAM #include namespace vectorial::io { template >, std::negation>>>, std::nullptr_t> = nullptr> struct OutputStream { private: using ostream_type = std::remove_reference_t; OStream os; public: template OutputStream(OStream_ &&os) : os(std::move(os)) {} template OutputStream(OStream_ &os) : os(os) {} template OutputStream& operator<<(const T& e) { if constexpr (vectorial::is_writable_v) os << e; else _print(e); return *this; } void print() { *this << '\n'; } template void print(const Head& head, const Tail &...tails) { *this << head, ((*this << ' ' << tails), ...), *this << '\n'; } template , std::nullptr_t> = nullptr> void print_all(const Iterable& v, std::string sep = " ", std::string end = "\n") { for (auto it = v.begin(); it != v.end();) if (*this << *it; ++it != v.end()) *this << sep; *this << end; } ostream_type& get_stream() { return os; } private: void _print(__uint128_t value) { char buffer[41], *d = std::end(buffer); do *--d = '0' + (value % 10), value /= 10; while (value); os.rdbuf()->sputn(d, std::end(buffer) - d); } void _print(__int128_t value) { if (value < 0) *this << '-'; _print(__uint128_t(value < 0 ? -value : value)); } template void _print(const std::pair& a) { *this << a.first << ' ' << a.second; } template void _print(const std::tuple& a) { if constexpr (N < std::tuple_size_v>) { if constexpr (N) *this << ' '; *this << std::get(a), _print(a); } } template , std::nullptr_t> = nullptr> void _print(const Iterable& a) { print_all(a, " ", ""); } }; template OutputStream(OStream_ &&) -> OutputStream; template OutputStream(OStream_ &) -> OutputStream; OutputStream cout{ std::cout }, cerr{ std::cerr }; template void print(const Args &... args) { cout.print(args...); } template , std::nullptr_t> = nullptr> void print_all(const Iterable& v, const std::string& sep = " ", const std::string& end = "\n") { cout.print_all(v, sep, end); } } namespace vectorial { using io::print, io::print_all; } #endif namespace vectorial { template , std::enable_if_t, std::is_invocable_r, std::invoke_result_t>>, std::nullptr_t> = nullptr> auto comparator(const ToKey& to_key, const CompKey& comp_key = std::less<>()) { return [=](const T& x, const T& y) { return comp_key(to_key(x), to_key(y)); }; } template , std::nullptr_t> = nullptr> std::vector sorted_indices(int n, const Compare& compare) { std::vector p(n); return std::iota(p.begin(), p.end(), 0), std::sort(p.begin(), p.end(), compare), p; } template , std::nullptr_t> = nullptr> std::vector sorted_indices(int n, const ToKey& to_key) { return sorted_indices(n, comparator(to_key)); } template auto priority_queue_with_comparator(const Comparator& comparator) { return std::priority_queue, Comparator>{ comparator }; } template , std::nullptr_t> = nullptr> void sort_unique_erase(Iterable& a) { std::sort(a.begin(), a.end()), a.erase(std::unique(a.begin(), a.end()), a.end()); } template struct Dim : std::array { template Dim(const Ints& ...ns) : std::array::array{ static_cast(ns)... } {} }; template Dim(const Ints& ...) -> Dim; template auto ndvec(const Dim &ns, const T& value = {}) { if constexpr (I + 1 < D) { return std::vector(ns[I], ndvec(ns, value)); } else { return std::vector(ns[I], value); } } } namespace vectorial { using int128 = __int128_t; using uint128 = __uint128_t; template using min_priority_queue = std::priority_queue, std::greater>; template using max_priority_queue = std::priority_queue, std::less>; } namespace vectorial { const std::string Yes = "Yes", No = "No", YES = "YES", NO = "NO"; } #ifdef LOCAL # define debug(...) debug_impl(#__VA_ARGS__, __VA_ARGS__) template void debug_impl(const char* s, const H& h, const Ts&... t) { vectorial::io::cerr << "[\033[32mDEBUG\033[m] " << s << ": " << h, ((vectorial::io::cerr << ", " << t), ..., (vectorial::io::cerr << "\n")); } #else # define debug(...) void(0) #endif #define FOR(e, v) for (auto &&e : v) #define CFOR(e, v) for (const auto &e : v) #define REP(i, ...) CFOR(i, vectorial::macro::rep_impl(__VA_ARGS__)) #define RREP(i, ...) CFOR(i, vectorial::macro::rrep_impl(__VA_ARGS__)) #define REPINF(i, ...) CFOR(i, vectorial::macro::repinf_impl(__VA_ARGS__)) #define LOOP(n) for ([[maybe_unused]] const auto& _ : vectorial::macro::rep_impl(n)) #define ALL(iterable) std::begin(iterable), std::end(iterable) #ifndef VECTORIAL_MOBIUS_FUNCTION #define VECTORIAL_MOBIUS_FUNCTION #include #include #include namespace vectorial { template class MobiusFunction { public: MobiusFunction() { mpf.fill(0); dat.fill(1); for (long long p = 2; p <= N; ++p) { if (mpf[p]) continue; mpf[p] = p; dat[p] = -1; for (long long q = p * 2; q <= N; q += p) { if (not mpf[q]) mpf[q] = p; dat[q] = q % (p * p) ? -dat[q] : 0; } } } int operator()(unsigned int n) const { assert(0 < n and n <= N); return dat[n]; } int operator[](unsigned int n) const { return (*this)(n); } int mobius(unsigned int n) const { return (*this)(n); } int min_prime_factor(unsigned int n) const { assert(2 <= n and n <= N); return mpf[n]; } std::vector> factorize(unsigned int n) const { assert(0 < n and n <= N); std::vector> prime_powers; while (n > 1) { int p = mpf[n], c = 0; do { n /= p, ++c; } while (n % p == 0); prime_powers.emplace_back(p, c); } return prime_powers; } bool is_prime(unsigned int n) const { assert(n <= N); return 2 <= n and mpf[n] == n; } private: std::array mpf; std::array dat; }; } #endif #ifndef VECTORIAL_MODINT #define VECTORIAL_MODINT #include #include #include #include #include namespace vectorial { namespace internal::modint { constexpr long long safe_mod(long long x, long long m) { return (x %= m) < 0 ? x + m : x; } constexpr long long pow_mod(long long x, long long n, int m) { if (m == 1) return 0; unsigned int um = m; unsigned long long r = 1, y = safe_mod(x, m); for (; n; n >>= 1) { if (n & 1) r = (r * y) % um; y = (y * y) % um; } return r; } constexpr bool is_prime(int n) { if (n <= 1) return false; if (n == 2 or n == 7 or n == 61) return true; if (n % 2 == 0) return false; long long d = n - 1; while (d % 2 == 0) d /= 2; constexpr long long bases[3] = { 2, 7, 61 }; for (long long a : bases) { long long t = d, y = pow_mod(a, t, n); for (; t != n - 1 and y != 1 and y != n - 1; t <<= 1) y = y * y % n; if (y != n - 1 and t % 2 == 0) return false; } return true; } constexpr std::pair inv_gcd(long long a, long long b) { a = safe_mod(a, b); if (a == 0) return { b, 0 }; long long s = b, t = a, m0 = 0, m1 = 1, tmp = 0; while (t) { long long u = s / t; s -= t * u, m0 -= m1 * u; tmp = s, s = t, t = tmp; tmp = m0, m0 = m1, m1 = tmp; } if (m0 < 0) m0 += b / s; return { s, m0 }; } struct barrett_K128 { uint32_t M; __uint128_t L; uint64_t dL, uL; constexpr barrett_K128(uint32_t M) : M(M), L(~__uint128_t(0) / M + 1), dL(L), uL(L >> 64) {} constexpr uint32_t umod() const { return M; } template constexpr uint32_t rem(uint64_t c) const { if constexpr (care_M1) if (M == 1) return 0; __uint128_t cu = __uint128_t(c) * uL; uint64_t cd = (__uint128_t(c) * dL) >> 64; uint32_t r = c - uint64_t(cu >> 64) * M; return uint64_t(cu) > ~cd ? r - M : r; } constexpr uint32_t mul(uint32_t a, uint32_t b) const { return rem(uint64_t(a) * b); } }; } template = nullptr> class static_modint { using mint = static_modint; struct raw_construct {}; constexpr static_modint(int v, raw_construct) : _v(v) {} public: static constexpr int mod() { return m; } static constexpr unsigned int umod() { return m; } static constexpr mint raw(int v) { return mint(v, raw_construct{}); } constexpr static_modint() : _v(0) {} template , std::is_signed>, std::nullptr_t> = nullptr> constexpr static_modint(T v) : _v{} { int x = v % mod(); if (x < 0) x += mod(); _v = x; } template , std::is_unsigned>, std::nullptr_t> = nullptr> constexpr static_modint(T v) : _v(v % umod()) {} constexpr unsigned int val() const { return _v; } constexpr mint& operator++() { ++_v; if (_v == umod()) _v = 0; return *this; } constexpr mint& operator--() { if (_v == 0) _v = umod(); --_v; return *this; } constexpr mint operator++(int) { mint x = *this; ++*this; return x; } constexpr mint operator--(int) { mint x = *this; --*this; return x; } constexpr mint& operator+=(const mint& rhs) { _v += rhs._v; if (_v >= umod()) _v -= umod(); return *this; } constexpr mint& operator-=(const mint& rhs) { _v -= rhs._v; if (_v >= umod()) _v += umod(); return *this; } constexpr mint& operator*=(const mint& rhs) { _v = (unsigned long long) _v * rhs._v % umod(); return *this; } constexpr mint& operator/=(const mint& rhs) { return *this *= rhs.inv(); } constexpr mint operator+() const { return *this; } constexpr mint operator-() const { return _v == 0 ? *this : raw(umod() - _v); } constexpr mint pow(long long n) const { assert(0 <= n); mint x = *this, r = 1; for (; n; n >>= 1) { if (n & 1) r *= x; x *= x; } return r; } constexpr mint xpow(long long n) const { return n < 0 ? inv().pow(-n) : pow(n); } constexpr mint inv() const { if constexpr (is_prime_mod) { assert(_v); return pow(umod() - 2); } else { const auto [g, res] = internal::modint::inv_gcd(_v, mod()); assert(g == 1); return res; } } friend constexpr mint operator+(const mint& lhs, const mint& rhs) { mint res = lhs; res += rhs; return res; } friend constexpr mint operator-(const mint& lhs, const mint& rhs) { mint res = lhs; res -= rhs; return res; } friend constexpr mint operator*(const mint& lhs, const mint& rhs) { mint res = lhs; res *= rhs; return res; } friend constexpr mint operator/(const mint& lhs, const mint& rhs) { mint res = lhs; res /= rhs; return res; } friend constexpr bool operator==(const mint& lhs, const mint& rhs) { return lhs._v == rhs._v; } friend constexpr bool operator!=(const mint& lhs, const mint& rhs) { return lhs._v != rhs._v; } private: unsigned int _v; static constexpr bool is_prime_mod = internal::modint::is_prime(mod()); }; template class dynamic_modint { using mint = dynamic_modint; using barrett = internal::modint::barrett_K128; struct raw_construct {}; constexpr dynamic_modint(int v, raw_construct) : _v(v) {} public: static int mod() { return bt.umod(); } static unsigned int umod() { return bt.umod(); } static void set_mod(int m) { assert(1 <= m); bt = barrett(m); } static mint raw(int v) { return dynamic_modint(v, raw_construct{}); } dynamic_modint() : _v(0) {} template , std::is_signed>, std::nullptr_t> = nullptr> dynamic_modint(T v) { if (v < 0) { int x = v % mod(); if (x < 0) x += mod(); _v = x; } else _v = bt.rem(v); } template , std::is_unsigned>, std::nullptr_t> = nullptr> dynamic_modint(T v) : _v(bt.rem(v)) {} dynamic_modint(__uint128_t v) : _v(v % umod()) {} dynamic_modint(__int128_t v) { int x = v % mod(); if (x < 0) x += mod(); _v = x; } unsigned int val() const { return _v; } mint& operator++() { ++_v; if (_v == umod()) _v = 0; return *this; } mint& operator--() { if (_v == 0) _v = umod(); --_v; return *this; } mint operator++(int) { mint x = *this; ++*this; return x; } mint operator--(int) { mint x = *this; --*this; return x; } mint& operator+=(const mint& rhs) { _v += rhs._v; if (_v >= umod()) _v -= umod(); return *this; } mint& operator-=(const mint& rhs) { _v -= rhs._v; if (_v >= umod()) _v += umod(); return *this; } mint& operator*=(const mint& rhs) { _v = bt.mul(_v, rhs._v); return *this; } mint& operator/=(const mint& rhs) { return *this *= rhs.inv(); } mint pow(long long n) const { assert(0 <= n); mint x = *this, r = 1; for (; n; n >>= 1) { if (n & 1) r *= x; x *= x; } return r; } mint xpow(long long n) const { return n < 0 ? inv().pow(-n) : pow(n); } mint inv() const { const auto [g, res] = internal::modint::inv_gcd(_v, mod()); assert(g == 1); return res; } friend mint operator+(const mint& lhs, const mint& rhs) { mint res = lhs; res += rhs; return res; } friend mint operator-(const mint& lhs, const mint& rhs) { mint res = lhs; res -= rhs; return res; } friend mint operator*(const mint& lhs, const mint& rhs) { mint res = lhs; res *= rhs; return res; } friend mint operator/(const mint& lhs, const mint& rhs) { mint res = lhs; res /= rhs; return res; } friend bool operator==(const mint& lhs, const mint& rhs) { return lhs._v == rhs._v; } friend bool operator!=(const mint& lhs, const mint& rhs) { return lhs._v != rhs._v; } private: unsigned int _v; static inline barrett bt{ 998244353 }; }; using modint998244353 = static_modint<998244353>; using modint1000000007 = static_modint<1000000007>; using modint = dynamic_modint<-1>; template struct is_modint : std::false_type {}; template struct is_modint> : std::true_type {}; template struct is_modint> : std::true_type {}; template constexpr bool is_modint_v = is_modint::value; template struct is_static_modint : std::false_type {}; template struct is_static_modint> : std::true_type {}; template constexpr bool is_static_modint_v = is_static_modint::value; template struct is_dynamic_modint : std::false_type {}; template struct is_dynamic_modint> : std::true_type {}; template constexpr bool is_dynamic_modint_v = is_dynamic_modint::value; template , std::nullptr_t> = nullptr> std::optional mod_sqrt(mint a) { const int p = mint::mod(); if (a == 0) return mint(0); if (p == 2) return a; if (a.pow((p - 1) / 2) != 1) return std::nullopt; mint b = 1; while (b.pow((p - 1) / 2) == 1) ++b; const int tlz = __builtin_ctz(p - 1), q = (p - 1) >> tlz; mint x = a.pow((q + 1) / 2); b = b.pow(q); for (int shift = 2; x * x != a; ++shift) { mint e = a.inv() * x * x; if (e.pow(1 << (tlz - shift)) != 1) x *= b; b *= b; } return x; } template , std::nullptr_t> = nullptr> mint sqrt(mint a) { return *mod_sqrt(a); } template , std::nullptr_t> = nullptr> mint log(mint a) { assert(a == 1); return 0; } template , std::nullptr_t> = nullptr> mint exp(mint a) { assert(a == 0); return 1; } template , std::nullptr_t> = nullptr> mint pow(mint a, T b) { return a.xpow(b); } template , std::nullptr_t> = nullptr> mint inv(mint a) { return a.inv(); } template , std::nullptr_t> = nullptr> std::istream& operator>>(std::istream& is, mint& v) { long long val; is >> val, v = val; return is; } template , std::nullptr_t> = nullptr> std::ostream& operator<<(std::ostream& os, const mint& v) { return os << v.val(); } } #endif using namespace std; using namespace vectorial; using mint = modint998244353; MobiusFunction<10000000> mu; signed main() { int N, M; read(N, M); mint ans = 0; REP(d, 1, min(N, M) + 1) { long long n = N / d, m = M / d; ans += mint(mu[d]) * d * d * mint(n * (n + 1) / 2) * mint(m * (m + 1) / 2); } print(ans); }