#include using namespace std; #include using mint = atcoder::modint998244353; void solve() { long long N, M; cin >> N >> M; long long r = N%(2*M); if(r == 0) { cout << 0 << endl; }else if(r <= M) { cout << mint(mint(10).pow(r) - mint(1)).val() << endl; }else { cout << mint(mint(mint(10).pow(2*M-r) - mint(1)) * mint(10).pow(r-M)).val() << endl; } } int main() { int T; cin >> T; while(T--) { solve(); } }