#include<bits/stdc++.h>
#include<atcoder/modint>

int main(){
    using namespace std;
    using modint = atcoder::static_modint<1000000007>;
    const auto [A, D0, D1, D2, D3]{[]{
        unsigned long a, b;
        cin >> a >> b;
        return make_tuple(a, (b + 4) / 4, (b + 3) / 4, (b + 2) / 4, (b + 1) / 4);
    }()};
    const auto [G0, G1, G2, G3]{[]{
        long X, Y;
        cin >> X >> Y;
        return tuple<unsigned long, unsigned long, unsigned long, unsigned long>{X > 0 ? X : 0, Y > 0 ? Y : 0, X < 0 ? -X : 0, Y < 0 ? -Y : 0};
    }()};
    if(((G0 ^ G1 ^ G2 ^ G3 ^ A) & 1) || (A < G0 + G1 + G2 + G3)){
        cout << '0' << endl;
        return 0;
    }
    
    const auto S{(A - G0 - G1 - G2 - G3) / 2};
    const auto N{max({D0 + G0, D1 + G1, D2 + G2, D3 + G3}) + S};

    vector<modint> fact{1};
    fact.reserve(N + 1);
    for(unsigned long i{1}; i <= N; ++i)fact.emplace_back(fact.back() * modint::raw(i));
    vector<modint> ifact{fact.back().inv()};
    ifact.reserve(N + 1);
    for(unsigned long i{N}; i; --i)ifact.emplace_back(ifact.back() * modint::raw(i));
    reverse(begin(ifact), end(ifact));

    modint ans{};
    const auto query{[&fact, &ifact](unsigned long x, unsigned long y){
        return x ? fact[x + y - 1] * ifact[y] * ifact[x - 1] : modint::raw(!y);
    }};
    for(unsigned long i{}; i <= S; ++i)ans += query(D0, G0 + i) * query(D1, G1 + S - i) * query(D2, G2 + i) * query(D3, G3 + S - i);
    cout << ans.val() << endl;
    return 0;
}