#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using Int = long long; template ostream &operator<<(ostream &os, const pair &a) { return os << "(" << a.first << ", " << a.second << ")"; }; template ostream &operator<<(ostream &os, const vector &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; } template void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; } template bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; } template bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; } //////////////////////////////////////////////////////////////////////////////// template struct ModInt { static constexpr unsigned M = M_; unsigned x; constexpr ModInt() : x(0U) {} constexpr ModInt(unsigned x_) : x(x_ % M) {} constexpr ModInt(unsigned long long x_) : x(x_ % M) {} constexpr ModInt(int x_) : x(((x_ %= static_cast(M)) < 0) ? (x_ + static_cast(M)) : x_) {} constexpr ModInt(long long x_) : x(((x_ %= static_cast(M)) < 0) ? (x_ + static_cast(M)) : x_) {} ModInt &operator+=(const ModInt &a) { x = ((x += a.x) >= M) ? (x - M) : x; return *this; } ModInt &operator-=(const ModInt &a) { x = ((x -= a.x) >= M) ? (x + M) : x; return *this; } ModInt &operator*=(const ModInt &a) { x = (static_cast(x) * a.x) % M; return *this; } ModInt &operator/=(const ModInt &a) { return (*this *= a.inv()); } ModInt pow(long long e) const { if (e < 0) return inv().pow(-e); ModInt a = *this, b = 1U; for (; e; e >>= 1) { if (e & 1) b *= a; a *= a; } return b; } ModInt inv() const { unsigned a = M, b = x; int y = 0, z = 1; for (; b; ) { const unsigned q = a / b; const unsigned c = a - q * b; a = b; b = c; const int w = y - static_cast(q) * z; y = z; z = w; } assert(a == 1U); return ModInt(y); } ModInt operator+() const { return *this; } ModInt operator-() const { ModInt a; a.x = x ? (M - x) : 0U; return a; } ModInt operator+(const ModInt &a) const { return (ModInt(*this) += a); } ModInt operator-(const ModInt &a) const { return (ModInt(*this) -= a); } ModInt operator*(const ModInt &a) const { return (ModInt(*this) *= a); } ModInt operator/(const ModInt &a) const { return (ModInt(*this) /= a); } template friend ModInt operator+(T a, const ModInt &b) { return (ModInt(a) += b); } template friend ModInt operator-(T a, const ModInt &b) { return (ModInt(a) -= b); } template friend ModInt operator*(T a, const ModInt &b) { return (ModInt(a) *= b); } template friend ModInt operator/(T a, const ModInt &b) { return (ModInt(a) /= b); } explicit operator bool() const { return x; } bool operator==(const ModInt &a) const { return (x == a.x); } bool operator!=(const ModInt &a) const { return (x != a.x); } friend std::ostream &operator<<(std::ostream &os, const ModInt &a) { return os << a.x; } }; //////////////////////////////////////////////////////////////////////////////// constexpr unsigned MO = 998244353; using Mint = ModInt; Mint f0[4][4][4][4][4][4][4]; Mint f1[4][4][4][4][5][5][5]; Mint f2[4][4][4][4][6][6][6]; Mint f3[4][4][4][4][7][7][7]; #define rep(i, n) for (int i = 0; i < n; ++i) int main() { Int A[4], B[4]; for (; ~scanf("%lld", &A[0]); ) { for (int x = 1; x < 4; ++x) scanf("%lld", &A[x]); for (int y = 0; y < 4; ++y) scanf("%lld", &B[y]); for (int x = 0; x < 4; ++x) A[x] -= 4; for (int y = 0; y < 4; ++y) B[y] -= 4; Mint ans = 0; if (A[0] + A[1] + A[2] + A[3] == B[0] + B[1] + B[2] + B[3]) { memset(f0, 0, sizeof(f0)); f0[0][0][0][0][0][0][0] = 1; for (int e = 0; e < 30; ++e) { int as[4], bs[4]; for (int x = 0; x < 4; ++x) as[x] = A[x] >> e & 1; for (int y = 0; y < 4; ++y) bs[y] = B[y] >> e & 1; memset(f1, 0, sizeof(f1)); rep(x0, 4) rep(x1, 4) rep(x2, 4) rep(x3, 4) { rep(z0, 2) rep(z1, 2) rep(z2, 2) rep(z3, 2) { const int s = x0 + (z0 + z1 + z2 + z3); if ((s & 1) == as[0]) { rep(y0, 4) rep(y1, 4) rep(y2, 4) { f1[s >> 1][x1][x2][x3][y0 + z0][y1 + z1][y2 + z2] += f0[x0][x1][x2][x3][y0][y1][y2]; } } } } memset(f2, 0, sizeof(f2)); rep(x0, 4) rep(x1, 4) rep(x2, 4) rep(x3, 4) { rep(z0, 2) rep(z1, 2) rep(z2, 2) rep(z3, 2) { const int s = x1 + (z0 + z1 + z2 + z3); if ((s & 1) == as[1]) { rep(y0, 5) rep(y1, 5) rep(y2, 5) { f2[x0][s >> 1][x2][x3][y0 + z0][y1 + z1][y2 + z2] += f1[x0][x1][x2][x3][y0][y1][y2]; } } } } memset(f3, 0, sizeof(f3)); rep(x0, 4) rep(x1, 4) rep(x2, 4) rep(x3, 4) { rep(z0, 2) rep(z1, 2) rep(z2, 2) rep(z3, 2) { const int s = x2 + (z0 + z1 + z2 + z3); if ((s & 1) == as[2]) { rep(y0, 6) rep(y1, 6) rep(y2, 6) { f3[x0][x1][s >> 1][x3][y0 + z0][y1 + z1][y2 + z2] += f2[x0][x1][x2][x3][y0][y1][y2]; } } } } memset(f0, 0, sizeof(f0)); rep(x0, 4) rep(x1, 4) rep(x2, 4) rep(x3, 4) { rep(z0, 2) rep(z1, 2) rep(z2, 2) rep(z3, 2) { const int s = x3 + (z0 + z1 + z2 + z3); if ((s & 1) == as[3]) { for (int y0 = (bs[0] - z0) & 1; y0 < 7; y0 += 2) for (int y1 = (bs[1] - z1) & 1; y1 < 7; y1 += 2) for (int y2 = (bs[2] - z2) & 1; y2 < 7; y2 += 2) { f0[x0][x1][x2][s >> 1][(y0 + z0) >> 1][(y1 + z1) >> 1][(y2 + z2) >> 1] += f3[x0][x1][x2][x3][y0][y1][y2]; } } } } } ans += f0[0][0][0][0][0][0][0]; } printf("%u\n", ans.x); } return 0; }