#include #include using namespace std; using namespace atcoder; //const long nPrime = 1000000007; const long nPrime = 998244353; typedef long long ll; //const long nPrime = 1000000007; long LF_Pow(long nBase, long nExp){ if(nExp < 0){ return -1; } long iTmp = nBase % nPrime; long nReturn = 1; while (nExp > 0){ if(nExp % 2 == 1){ nReturn *= iTmp; nReturn %= nPrime; } iTmp = iTmp * iTmp; iTmp %= nPrime; nExp /= 2; } return nReturn; } int main() { ll n,m; cin >> n >> m; vector viNum; while(n > 0){ viNum.push_back(n%2); n /= 2; } ll k = viNum.size(); if(m < 1000){ vector viAns(m+k,0); for(ll i = 0; i < m; i++){ for(ll j = 0; j < k; j++){ viAns[i+j] ^= viNum[j]; } } ll nAns = 0; ll iOrd = 1; for(ll i = 0; i < m+k; i++){ nAns += viAns[i] * iOrd; nAns %= nPrime; iOrd *= 2; iOrd %= nPrime; } cout << nAns << endl; return 0; } vector viFront(k+1,0), viBack(k+1,0); for(ll i = 0; i < k; i++){ viFront[i+1] = viFront[i]^viNum[i]; viBack[i+1] = viBack[i]^viNum[k-i-1]; } ll nBit = viFront[k]; ll nAns = 0; for(ll i = 0; i < k; i++){ nAns += viFront[i+1] * LF_Pow(2,i); nAns += viBack[i+1] * LF_Pow(2,m+k-2-i); nAns %= nPrime; } ll iThis = LF_Pow(2,m-1) - LF_Pow(2,k) + nPrime; nAns += iThis * nBit; nAns %= nPrime; cout << nAns << endl; return 0; }