#include #include #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") using namespace std; using mint = atcoder::modint998244353; int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); int T; cin >> T; while(T--) { int N, M; cin >> N >> M; if(N % (M * 2) == 0) { cout << 0 << '\n'; } else { cout << (mint(10).pow(N % (M * 2)) - 1).val() << '\n'; } } return 0; }