#include <cstdio>
typedef unsigned int ui32_t;
ui32_t Pos[2][16][16][16][16][32];
ui32_t A[5], TotalExp, a, b, c, d, e;
int i;
ui32_t K=0;
inline void Do(ui32_t e){
    if((e&3)==3){
        Pos[K][a][b][c][d][e^3]+=Pos[K][a][b][c][d][e];
        Pos[K][a][b][c][d][e^3]%=1000000007;
    }
    if((e&6)==6){
        Pos[K][a][b][c][d][e^6]+=Pos[K][a][b][c][d][e];
        Pos[K][a][b][c][d][e^6]%=1000000007;
    }
    if((e&12)==12){
        Pos[K][a][b][c][d][e^12]+=Pos[K][a][b][c][d][e];
        Pos[K][a][b][c][d][e^12]%=1000000007;
    }
    if((e&24)==24){
        Pos[K][a][b][c][d][e^24]+=Pos[K][a][b][c][d][e];
        Pos[K][a][b][c][d][e^24]%=1000000007;
    }
    if((e&17)==17){
        Pos[K][a][b][c][d][e^17]+=Pos[K][a][b][c][d][e];
        Pos[K][a][b][c][d][e^17]%=1000000007;
    }
    return;
}
const ui32_t Order32BCDesc[]={
    31,
    30,29,27,23,15,
    28,26,25,22,21,19,14,13,11,7,
    24,20,18,17,12,10,9,6,5,3,
    16,8,4,2,1,
    0
};
ui32_t Exp(ui32_t a){
    ui32_t E=0;
    while(1<<E<=a) E++;
    return E-1;
}
int main(){
    scanf("%u %u %u %u %u", A, A+1, A+2, A+3, A+4);
    TotalExp=Exp(A[0])+Exp(A[1])+Exp(A[2])+Exp(A[3])+Exp(A[4]);
    Pos[K][Exp(A[0])][Exp(A[1])][Exp(A[2])][Exp(A[3])][((A[0]&1)<<4)+((A[1]&1)<<3)+((A[2]&1)<<2)+((A[3]&1)<<1)+((A[4]&1)<<0)]=1;
    if(TotalExp%2==1){
        printf("%u\n", 0);
    }
    for(i=TotalExp;i>=0;i-=2){
        for(a=0;a<16;a++){
            for(b=0;b<16;b++){
                for(c=0;c<16;c++){
                    for(d=0;d<16;d++){
                        for(e=0;e<32;e++){
                            Pos[K^1][a][b][c][d][e]=0;
                        }
                    }
                }
            }
        }
        for(a=0;a<16;a++){
            for(b=0;b<16;b++){
                for(c=0;c<16;c++){
                    for(d=0;d<16;d++){
                        for(e=0;e<32;e++){
                            if(Pos[K][a][b][c][d][e]==0) continue;
                            if(a!=0&&b!=0){
                                Pos[K^1][a-1][b-1][c][d][((A[0]&(1<<a-1))?16:0)+((A[1]&(1<<b-1))?8:0)+(e&7)]+=Pos[K][a][b][c][d][e];
                                Pos[K^1][a-1][b-1][c][d][((A[0]&(1<<a-1))?16:0)+((A[1]&(1<<b-1))?8:0)+(e&7)]%=1000000007;
                            }
                            if(b!=0&&c!=0){
                                Pos[K^1][a][b-1][c-1][d][((A[1]&(1<<b-1))?8:0)+((A[2]&(1<<c-1))?4:0)+(e&19)]+=Pos[K][a][b][c][d][e];
                                Pos[K^1][a][b-1][c-1][d][((A[1]&(1<<b-1))?8:0)+((A[2]&(1<<c-1))?4:0)+(e&19)]%=1000000007;
                            }
                            if(c!=0&&d!=0){
                                Pos[K^1][a][b][c-1][d-1][((A[2]&(1<<c-1))?4:0)+((A[3]&(1<<d-1))?2:0)+(e&25)]+=Pos[K][a][b][c][d][e];
                                Pos[K^1][a][b][c-1][d-1][((A[2]&(1<<c-1))?4:0)+((A[3]&(1<<d-1))?2:0)+(e&25)]%=1000000007;
                            }
                            if(d!=0&&i-a-b-c-d!=0){
                                Pos[K^1][a][b][c][d-1][((A[3]&(1<<d-1))?2:0)+((A[4]&(1<<i-a-b-c-d-1))?2:0)+(e&28)]+=Pos[K][a][b][c][d][e];
                                Pos[K^1][a][b][c][d-1][((A[3]&(1<<d-1))?2:0)+((A[4]&(1<<i-a-b-c-d-1))?2:0)+(e&28)]%=1000000007;
                            }
                            if(a!=0&&i-a-b-c-d!=0){
                                Pos[K^1][a-1][b][c][d][((A[0]&(1<<a-1))?16:0)+((A[4]&(1<<i-a-b-c-d-1))?2:0)+(e&14)]+=Pos[K][a][b][c][d][e];
                                Pos[K^1][a-1][b][c][d][((A[0]&(1<<a-1))?16:0)+((A[4]&(1<<i-a-b-c-d-1))?2:0)+(e&14)]%=1000000007;
                            }
                        }
                    }
                }
            }
        }
        K^=1;
    }
    printf("%u\n", Pos[0][0][0][0][0][0]);
    return 0;
}
