/*
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;

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{
        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{
        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;

int get( State &s ){
    if( dp.find( s ) != dp.end() )
        return dp[s];
    
    ll &self = dp[s];
    
    self = 0;
    
    for( int i = 0 ; i < 5 ; i++ ){
        if( ( s.a[i] % 2 == 1 ) && ( s.a[ (i+1)%5 ] % 2 == 1 ) ){
            s.a[i]--;
            s.a[ (i+1)%5 ]--;
            
            self += get( s );
            self %= MOD;
            
            s.a[i]++;
            s.a[ (i+1)% 5]++;
        }
        if( s.a[i] and s.a[ (i+1) % 5 ] ){
            int a = s.a[i], b = s.a[ (i+1)%5 ];
            s.a[i] >>= 1;
            s.a[ (i+1) % 5 ] >>= 1;
            self += get( s );
            self %= MOD;
            s.a[i] = a, s.a[ (i+1)%5 ] = 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];
	
	dp[ State(0,0,0,0,0) ] = 1;
	
	cout << get( s ) << endl;
	
	return 0;
}
