#include #include using namespace std; using ll = long long; using mint = atcoder::modint998244353; int main() { ios::sync_with_stdio(false); cin.tie(0); int T; cin >> T; while(T--){ array A, B; cin >> A[0] >> A[1] >> A[2]; cin >> B[0] >> B[1] >> B[2]; ll MA = (B[0] + A[1] - 1) / A[1]; ll MB = (A[0] + B[1] - 1) / B[1]; mint coef = 1, ans = 0, div10 = mint(10).inv(), div100 = div10 * div10; coef = div10.pow(abs(MA - MB)); if(MA < MB) ans += 1 - coef; if(A[2] == B[2]){ ans += coef * mint(2).inv(); }else if(A[2] > B[2]){ ans += coef * 9 / (1 - div100) * div10; }else{ ans += coef * 9 / (1 - div100) * div100; } cout << ans.val() << '\n'; } }