#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include //#include #include using namespace std; using namespace atcoder; using ll=long long; using LL=__int128; using mint=modint998244353; using ld=long double; using pll=pair; using tu=tuple; using tu4=tuple; using vl=vector; using vb=vector; using vvb=vector; using vvl=vector; using vs=vector; using vld=vector; using vc=vector; using vmi=vector; using vp=vector; using vt=vector; using Graph=vector>>; using graph=vector>; template auto vec2(ll n,ll m,T x=T()){return vector(n,vector(m,x));} template auto vec3(ll n,ll m,ll l,T x=T()){return vector(n,vector(m,vector(l,x)));} template auto vec4(ll a,ll b,ll c,ll d,T x=T()){return vector(a,vector(b,vector(c,vector(d,x))));} template using rpq=priority_queue,greater>; using inverse_priority_queue=rpq; const ll Inf=2147483647LL, Inf9=1000000000LL, inf=9223372036854775807LL, inf18=1000000000000000000LL, mod=998244353LL; #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() #define rep(i,n) for(ll i=0;i<(ll)(n);i++) #define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--) #define rep1(i,n) for(ll i=1;i<=(ll)(n);i++) #define rep3(i,s,t) for(ll i=(ll)(s);i<(ll)(t);i++) #define pb push_back #define p(s) cout<<(s)<<'\n' #define p2(s,t) cout<<(s)<<" "<<(t)<<'\n' #define p3(s,t,u) cout<<(s)<<" "<<(t)<<" "<<(u)<<'\n' #define p4(s,t,u,v) cout<<(s)<<" "<<(t)<<" "<<(u)<<" "<<(v)<<'\n' #define pe(s) cout<<(s)<<' ' #define pval(s) cout<<(s).val()<<'\n' #define Sort(A) sort(all(A)) #define RSort(A) sort(rall(A)) #define p_yes() p("Yes") #define p_no() p("No") template inline ll sz(const T& x){return (ll)x.size();} ostream& operator<<(ostream& os,const mint& x){return os<>(istream& is,mint& x){ll v; is>>v; x=mint(v); return is;} template inline bool chmin(T& a,const T& b){if(a>b){a=b; return true;} return false;} template inline bool chmax(T& a,const T& b){if(a ll LB(const vector& v,const U& a){return lower_bound(all(v),a)-v.begin();} template ll UB(const vector& v,const U& a){return upper_bound(all(v),a)-v.begin();} template T vec_min(const vector& v){assert(!v.empty()); return *min_element(all(v));} template T vec_max(const vector& v){assert(!v.empty()); return *max_element(all(v));} template T vec_sum(const vector& v){T res=T(0); for(const auto& x:v) res+=x; return res;} template vector cin_vl(ll n){vector ret(n); rep(i,n) cin>>ret[i]; return ret;} template vector> cin_vvl(ll h,ll w){vector> ret(h,vector(w)); rep(i,h) rep(j,w) cin>>ret[i][j]; return ret;} template pair,vector> cin_xy(ll n){vector x(n),y(n); rep(i,n) cin>>x[i]>>y[i]; return {x,y};} template tuple,vector,vector> cin_xyz(ll n){vector x(n),y(n),z(n); rep(i,n) cin>>x[i]>>y[i]>>z[i]; return {x,y,z};} template vector> Cin_vl(ll n,ll k){vector> ret(k,vector(n)); rep(i,n) rep(j,k) cin>>ret[j][i]; return ret;} template vector> cin_pairs(ll n){vector> ret(n); rep(i,n) cin>>ret[i].first>>ret[i].second; return ret;} template vector> cin_tuples(ll n){vector> ret(n); rep(i,n){T a,b,c; cin>>a>>b>>c; ret[i]={a,b,c};} return ret;} template void cout_vl(const vector& a,char sep=' ',char end='\n'){rep(i,sz(a)){if(i) cout< void Cout_vl(const vector& a,const vector& b){rep(i,sz(a)) cout< void cout_vvl(const vector>& a){for(const auto& e:a) cout_vl(e);} ll ceil_div(ll a,ll b){assert(b!=0); if(b<0) a=-a,b=-b; if(a>=0) return (a+b-1)/b; return -((-a)/b);} ll floor_div(ll a,ll b){assert(b!=0); if(b<0) a=-a,b=-b; if(a>=0) return a/b; return -((-a+b-1)/b);} ll isqrt(ll n){ll x=sqrtl(n); while((LL)(x+1)*(x+1)<=n) x++; while((LL)x*x>n) x--; return x;} template vector sort_unique_vec(vector v){sort(all(v)); v.erase(unique(all(v)),v.end()); return v;} template vector compress(const vector& v){auto xs=sort_unique_vec(v); vector ret; for(auto& x:v) ret.pb(LB(xs,x)); return ret;} template vector prefix_sum(const vector& v){vector s(sz(v)+1,0); rep(i,sz(v)) s[i+1]=s[i]+v[i]; return s;} template T range_sum(const vector& s,ll l,ll r){return s[r]-s[l];} template vector> run_length(const vector& v){vector> ret; for(auto& x:v){if(ret.empty()||ret.back().first!=x) ret.pb({x,1}); else ret.back().second++;} return ret;} vector> run_length(const string& s){vector> ret; for(char c:s){if(ret.empty()||ret.back().first!=c) ret.pb({c,1}); else ret.back().second++;} return ret;} template ll argmin(const vector& v){assert(!v.empty()); return min_element(all(v))-v.begin();} template ll argmax(const vector& v){assert(!v.empty()); return max_element(all(v))-v.begin();} template bool in_vec(const vector& v,const T& x){return binary_search(all(v),x);} bool even(ll x){return x%2==0;} bool odd(ll x){return x%2!=0;} ll grid_id(ll x,ll y,ll w){return x*w+y;} pll grid_xy(ll id,ll w){return {id/w,id%w};} ll gcd(ll a,ll b){if(b==0) return abs(a); return gcd(b,a%b);} ll lcm(ll a,ll b){return a/gcd(a,b)*b;} ll Exp(ll x,ll y){ll cnt=-1; while(x>0) x/=y,cnt++; return cnt;} ll powmod(ll x,ll k,ll m){if(k==0) return 1%m; ll r=powmod(x,k/2,m); r=(LL)r*r%m; if(k&1) r=(LL)r*x%m; return r;} template T square(T x){return x*x;} template void Uni_erase(vector& v){sort(all(v)); v.erase(unique(all(v)),v.end());} inline bool OutIn(ll x,ll n){return 0<=x&&x dist(l,r-1); return dist(rng);} void YesNo(bool x){x?p_yes():p_no();} vl vl_n(ll n){vl ret(n); rep(i,n) ret[i]=i; return ret;} vl vl_N(ll n){vl ret(n); rep(i,n) ret[i]=i+1; return ret;} vl dx={0,1,0,-1}, dy={1,0,-1,0}; vl dx8={1,1,0,-1,-1,-1,0,1}, dy8={0,1,1,1,0,-1,-1,-1}; vector fac,finv; void factorial(ll N=1000000LL){ll M=N+100; fac.assign(M+1,1); finv.assign(M+1,1); rep1(i,M) fac[i]=fac[i-1]*i; finv[M]=fac[M].inv(); for(ll i=M;i>=1;i--) finv[i-1]=finv[i]*i;} void ensure_factorial(ll N){if((ll)fac.size()>N) return; factorial(N);} mint nCr(ll N,ll r){if(N<0||r<0||N> t;rep(i,t)solve(); } void solve(){ ll HC, AC, SC; ll HG, AG, SG; cin >> HC >> AC >> SC; cin >> HG >> AG >> SG; ll X = (HC-1)/AG + 1; ll Y = (HG-1)/AC + 1; mint ans; if(SC > SG){ if (Y <= X) { ll d = X - Y; mint q = 1; q /= mint(10).pow(d); ans = 1 - q/11; } else { ll d = Y - X; mint q = 1; q /= mint(10).pow(d); ans = q*10/11; } } else if(SC < SG){ if(X <= Y){ ll d = Y - X; mint q =1; q /= mint(10).pow(d); ans = q/11; } else { ll d = X - Y; mint q = 1; q /= mint(10).pow(d); ans = 1 - q*10/11; } } else{ if(X <= Y) { ll d = Y - X; mint q = 1; q /= mint(10).pow(d); ans = q/2; } else{ ll d = X - Y; mint q = 1; q /= mint(10).pow(d); ans = 1 - q/2; } } p(ans); }