/*
PROB: zero
LANG: C++
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <set>
#include <ext/hash_map>
#include <queue>
#include <map>
#include <stack>
#include <ctime>
#include <cmath>
#include <cstdlib>
#define foreach(a,b) for( typeof((b).begin()) a = (b).begin() ; a != (b).end() ; a++ )
#define eprintf( msg , ... ) fprintf( stderr , "Line %d in %s :: " msg "\n" , __LINE__ , __FUNCTION__ , ##__VA_ARGS__ )

using namespace std;
using namespace __gnu_cxx;

typedef long long ll;
typedef unsigned short uh;

const ll MOD = 1000LL * 1000LL * 1000LL + 7;
const int next[] = { 1, 2,3,4,0 };
const ll BASE = 30011LL;
const ll B[] = { 1 , BASE , BASE*BASE , BASE*BASE*BASE , BASE*BASE*BASE*BASE };

int cnt = 0;

struct State{
    uh a[5];
    State( uh __a, uh b , uh c ,uh d, uh e ){
        a[0] = __a;
        a[1] = b;
        a[2] = c;
        a[3] = d;
        a[4] = e;
    }
    State(){
        memset( a , 0 , sizeof( a ) );
    }
    inline bool operator==( const struct State &other ) const{
        cnt++;
        for( int i = 0 ; i < 5 ; i++ ) if( a[i] != other.a[i] ) return 0;
        return 1;
    }
};

struct hashstate{
    inline size_t operator()( const struct State &s ) const{
        /// super typata hash funkciq lele
        //return (ll) (s.a[0]*31LL) * (ll) (s.a[1]*17) * (ll) (s.a[2]*19) * (ll) (s.a[3]+13) * (ll) (s.a[4]);
        return ( (ll) (s.a[0]+12301LL) * (ll) (s.a[1]+5430LL) & ( ( 1 << 31 ) - 1 ) ) * (ll) (s.a[2]+4143LL) * (ll) (s.a[3]+10119LL) * (ll) (s.a[4]+9997LL);
        //return s.a[0]*B[0] + s.a[1]*B[1] + s.a[2]*B[2] + s.a[3]*B[3] + s.a[4]*B[4];
        //return ( ( (ll)s.a[0] ^ (ll) s.a[1]) * ( (ll) s.a[2] * (ll) s.a[3]) + (ll) s.a[0] * (ll) s.a[4] ) * (ll) s.a[1];
    }
};

State s;

hash_map< State , ll , hashstate > dp;

ll get( State &s ){
    typeof( dp.find( s ) ) it = dp.find( s );
    
    if( it != dp.end() )
        return it->second;
    
    ll &self = dp[s];
    
    self = 0;
    
    for( int i = 0 ; i < 5 ; i++ ){
        if( ( s.a[i] & 1 ) && ( s.a[ next[i] ] & 1 ) ){
            s.a[i]--;
            s.a[ next[i] ]--;
            
            self += get( s );
            
            if( self >= MOD ) self -= MOD;
            
            s.a[i]++;
            s.a[ next[i] ]++;
        }
        
        if( s.a[i] and s.a[ next[i] ] ){
            int a = s.a[i], b = s.a[ next[i] ];
            
            s.a[i] >>= 1;
            s.a[ next[i] ] >>= 1;
            self += get( s );
            
            if( self >= MOD ) self -= MOD;
            
            s.a[i] = a, s.a[ next[i] ] = b;
        }
    }
    
    ///eprintf("(%d,%d,%d,%d,%d) -> %lld", s.a[0], s.a[1], s.a[2], s.a[3], s.a[4], self);
    
    return self;
}

int main(){
	//freopen( "zero.in" , "r" , stdin );
	//freopen( "zero.out" , "w" , stdout );
	
	int a,b,c,d,e;
	
	///scanf("%uh %uh %uh %uh %uh", &s.a[0], &s.a[1], &s.a[2], &s.a[3], &s.a[4]);
	cin >> s.a[0] >> s.a[1] >> s.a[2] >> s.a[3] >> s.a[4];
	
	if( max( s.a[0] , max( s.a[1] , max( s.a[2] , max( s.a[3] , s.a[4] ) ) ) ) >= 5000 )
        dp.resize( 1 << 23 );
	
	dp[ State(0,0,0,0,0) ] = 1;
	
	cout << get( s ) % MOD << endl;
	/*
	cerr << cnt << " collisions" << endl;
	
    fprintf( stderr , "%.2lf" , (double) clock() / (double) CLOCKS_PER_SEC );
	*/
	return 0;
}
