#include #include using namespace std; using Int = atcoder::modint998244353; using LInt = __int128_t; Int f(LInt n){ return n < 0 ? 0 : (n+2) * (n+1) / 2; } Int Int_x0(Int n){ return n; } Int Int_x1(Int n){ return n * (n-1) / 2; } Int Int_x2(Int n){ return n * (n-1) * (2*n-1) / 6; } Int Int_x3(Int n){ return (n * (n-1) / 2).pow(2); } LInt Max(LInt a){ return a; } LInt Max(LInt a, LInt b){ return max(a, b); } LInt Max(LInt a, LInt b, LInt c){ return max(a, max(b, c)); } LInt Max(LInt a, LInt b, LInt c, LInt d){ return max(a, max(b, max(c, d))); } LInt Min(LInt a){ return a; } LInt Min(LInt a, LInt b){ return min(a, b); } LInt Min(LInt a, LInt b, LInt c){ return min(a, min(b, c)); } LInt Min(LInt a, LInt b, LInt c, LInt d){ return min(a, min(b, min(c, d))); } Int solve(LInt h1, LInt h2, LInt h3, LInt w1, LInt w2, LInt w3){ if(h1 + h2 + h3 != w1 + w2 + w3) return 0; LInt h = h2; LInt k = h1; Int ans = 0; Int static_coeff = (f(h) - f(h-(w1+w2+w3-k+3))); if (Max(0, k-w3-1-w2) < Min(k+1, w1+1)){ ans += (Int_x0(Min(k+1, w1+1)) - Int_x0(Max(0, k-w3-1-w2))) * (w2+1) * static_coeff; } if (Max(0, k-w3-1-w2, k-w2) < Min(k+1, w1+1)){ ans += (Int_x0(Min(k+1, w1+1)) - Int_x0(Max(0, k-w3-1-w2, k-w2))) * (k-w2) * static_coeff; ans += (Int_x1(Min(k+1, w1+1)) - Int_x1(Max(0, k-w3-1-w2, k-w2))) * (-1) * static_coeff; } if (Max(0, k-w3-1-w2) < Min(k+1, w1+1, k-w3+1)){ ans += (Int_x0(Min(k+1, w1+1, k-w3+1)) - Int_x0(Max(0, k-w3-1-w2))) * (w3-k) * static_coeff; ans += (Int_x1(Min(k+1, w1+1, k-w3+1)) - Int_x1(Max(0, k-w3-1-w2))) * (1) * static_coeff; } ans *= 2; for(int id=0; id<3; id++){ Int Coeff1X2 = -1; Int Coeff1X1 = -1+2*(-h+w1); Int Coeff1X0 = (-1)*(h-w1+1)*(h-w1); Int Coeff2X2 = 1; Int Coeff2X1 = 1-2*(h-w2-w3+k); Int Coeff2X0 = (h-w2-w3+k-1)*(h-w2-w3+k); if (Max(0, k-w3-1-w2, w1-h+1) < Min(k+1, w1+1)){ Int rangeL = Max(0, k-w3-1-w2, w1-h+1); Int rangeR = Min(k+1, w1+1); ans += (Int_x0(rangeR) - Int_x0(rangeL)) * (w2+1) * Coeff1X0; ans += (Int_x1(rangeR) - Int_x1(rangeL)) * (w2+1) * Coeff1X1; ans += (Int_x2(rangeR) - Int_x2(rangeL)) * (w2+1) * Coeff1X2; } if (Max(0, k-w3-1-w2, w1-h+1, k-w2) < Min(k+1, w1+1)){ Int rangeL = Max(0, k-w3-1-w2, w1-h+1, k-w2); Int rangeR = Min(k+1, w1+1); ans += (Int_x0(rangeR) - Int_x0(rangeL)) * (k-w2) * Coeff1X0; ans += (Int_x1(rangeR) - Int_x1(rangeL)) * (k-w2) * Coeff1X1; ans += (Int_x2(rangeR) - Int_x2(rangeL)) * (k-w2) * Coeff1X2; ans += (Int_x1(rangeR) - Int_x1(rangeL)) * (-1) * Coeff1X0; ans += (Int_x2(rangeR) - Int_x2(rangeL)) * (-1) * Coeff1X1; ans += (Int_x3(rangeR) - Int_x3(rangeL)) * (-1) * Coeff1X2; } if (Max(0, k-w3-1-w2, w1-h+1) < Min(k+1, w1+1, k-w3+1)){ Int rangeL = Max(0, k-w3-1-w2, w1-h+1); Int rangeR = Min(k+1, w1+1, k-w3+1); ans += (Int_x0(rangeR) - Int_x0(rangeL)) * (w3-k) * Coeff1X0; ans += (Int_x1(rangeR) - Int_x1(rangeL)) * (w3-k) * Coeff1X1; ans += (Int_x2(rangeR) - Int_x2(rangeL)) * (w3-k) * Coeff1X2; ans += (Int_x1(rangeR) - Int_x1(rangeL)) * (1) * Coeff1X0; ans += (Int_x2(rangeR) - Int_x2(rangeL)) * (1) * Coeff1X1; ans += (Int_x3(rangeR) - Int_x3(rangeL)) * (1) * Coeff1X2; } if (Max(0, k-w3-1-w2) < Min(k+1, w1+1, h-w2-w3+k-1)){ Int rangeL = Max(0, k-w3-1-w2); Int rangeR = Min(k+1, w1+1, h-w2-w3+k-1); ans += (Int_x0(rangeR) - Int_x0(rangeL)) * (w2+1) * Coeff2X0; ans += (Int_x1(rangeR) - Int_x1(rangeL)) * (w2+1) * Coeff2X1; ans += (Int_x2(rangeR) - Int_x2(rangeL)) * (w2+1) * Coeff2X2; } if (Max(0, k-w3-1-w2, k-w2) < Min(k+1, w1+1, h-w2-w3+k-1)){ Int rangeL = Max(0, k-w3-1-w2, k-w2); Int rangeR = Min(k+1, w1+1, h-w2-w3+k-1); ans += (Int_x0(rangeR) - Int_x0(rangeL)) * (k-w2) * Coeff2X0; ans += (Int_x1(rangeR) - Int_x1(rangeL)) * (k-w2) * Coeff2X1; ans += (Int_x2(rangeR) - Int_x2(rangeL)) * (k-w2) * Coeff2X2; ans += (Int_x1(rangeR) - Int_x1(rangeL)) * (-1) * Coeff2X0; ans += (Int_x2(rangeR) - Int_x2(rangeL)) * (-1) * Coeff2X1; ans += (Int_x3(rangeR) - Int_x3(rangeL)) * (-1) * Coeff2X2; } if (Max(0, k-w3-1-w2) < Min(k+1, w1+1, h-w2-w3+k-1, k-w3+1)){ Int rangeL = Max(0, k-w3-1-w2); Int rangeR = Min(k+1, w1+1, h-w2-w3+k-1, k-w3+1); ans += (Int_x0(rangeR) - Int_x0(rangeL)) * (w3-k) * Coeff2X0; ans += (Int_x1(rangeR) - Int_x1(rangeL)) * (w3-k) * Coeff2X1; ans += (Int_x2(rangeR) - Int_x2(rangeL)) * (w3-k) * Coeff2X2; ans += (Int_x1(rangeR) - Int_x1(rangeL)) * (1) * Coeff2X0; ans += (Int_x2(rangeR) - Int_x2(rangeL)) * (1) * Coeff2X1; ans += (Int_x3(rangeR) - Int_x3(rangeL)) * (1) * Coeff2X2; } LInt tmp = w1; w1 = w2; w2 = w3; w3 = tmp; } ans /= 2; return ans; } int main(){ long long h1, h2, h3, w1, w2, w3; cin >> h1 >> h2 >> h3 >> w1 >> w2 >> w3; h1 -= 3; h2 -= 3; h3 -= 3; w1 -= 3; w2 -= 3; w3 -= 3; Int ans = solve(h1, h2, h3, w1, w2, w3); cout << ans.val() << '\n'; return 0; }