#ifdef NACHIA #define _GLIBCXX_DEBUG #else #define NDEBUG #endif #include #include #include #include using i64 = long long; using u64 = unsigned long long; #define rep(i,n) for(int i=0; i void chmin(A& l, const A& r){ if(r < l) l = r; } template void chmax(A& l, const A& r){ if(l < r) l = r; } #include using Modint = atcoder::static_modint<998244353>; using namespace std; void testcase(){ auto proc = [&](vector f, Modint d) -> vector { if(d == 4) return { 0, f[0] + f[1], 0 }; if(d == 0) return { f[0] + f[2], 0, f[1] }; return { f[0] + f[1] + f[2], 0, 0 }; }; auto vadd = [&](vector& f, vector s, Modint t){ rep(x,3) f[x] += s[x] * t; }; vector st = { 1, 0, 0 }; vector dp(3); vector ex(3); bool beg = true; string N; cin >> N; for(char c : N){ i64 d = c - '0'; if(beg){ ex = proc(st, d); dp.assign(3, 0); rep(e,d) if(e != 0) vadd(dp, proc(st, e), 1); beg = false; } else { vector nx(3); i64 igcnt = d; if(0 < d){ igcnt--; vadd(nx, proc(ex, 0), 1); } if(4 < d){ igcnt--; vadd(nx, proc(ex, 4), 1); } vadd(nx, proc(ex, 1), igcnt); vadd(nx, proc(dp, 0), 1); vadd(nx, proc(dp, 4), 1); vadd(nx, proc(dp, 1), 8); nx[1] += 1; nx[0] += 8; ex = proc(ex, d); swap(dp, nx); } } vadd(dp, ex, 1); Modint ans = dp[0] + dp[1] + dp[2]; cout << ans.val() << endl; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); testcase(); return 0; }