#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)n; i++) using ll = long long int; #define MOD 998244353 int mod_pow(int x, int n) { int ret = 1; while (n > 0) { if ((n & 0x01) != 0) ret = (long long)ret * x % MOD; x = (long long)x * x % MOD; n >>= 1; } return ret; } int main() { int T; cin >> T; rep(i, T) { int N, M; cin >> N >> M; // 10^N - 1 = (10^M + 1)10^(N-M) - 10^(N-M) - 1 // = (10^M + 1)10^(N-M) - (10^(N-M) + 1) // (10^N - 1) % (10^M +1) = - (10^(N-M) + 1) / (10^M + 1) // 10^(N-M) + 1 = (10^M + 1)10^(N-2・M) - 10^(N-2・M) + 1 // = (10^M + 1)10^(N-2・M) - (10^(N-2・M) - 1) // (10^(N-M) + 1) % (10^M + 1) = - (10^(N-2・M) - 1) / (10^M + 1) // (10^N - 1) % (10^M + 1) = (10^(N-2・M) - 1) / (10^M + 1) // = (10^(N-2・M・k) - 1) / (10^M + 1) // N-2・M・k >= M ... ((10^(N-2・M・k) - 1) - (10^M + 1)) % MOD // N-2・M・k < M ... (10^(N-2・M・k) - 1) % MOD while (N >= 2*M) N -= 2*M; int ans; if (N >= M) { ans = (mod_pow(10, N) - mod_pow(10, N) - 2) % MOD; } else { ans = mod_pow(10, N) - 1; if (ans < 0) ans += MOD; } cout << ans << endl; } return 0; }