#include<bits/stdc++.h>
#define ll long long
#define M 1000000007

using namespace std;

int a[500];
int N1;

bool moze(int i, int j, int k, int l)
{
    i=(i-1)%N1+1;
    j=(j-1)%N1+1;
    k=(k-1)%N1+1;
    l=(l-1)%N1+1;
    return((a[i]^a[j]^a[k]^a[l])==1);
}

ll resi(int poc, int kraj, int n)
{
    if(kraj<=0) kraj+=12;
    //cout<<poc<<" "<<kraj<<" "<<n<<endl;
    if(n==4)
    {
        if(moze(poc,poc+1,poc+2,poc+3))
            return 1;
        return 0;
    }

    ll ret=0;
    if(moze(poc,poc+1,poc+2,poc+3))
        ret=(ret+resi(poc+4, kraj, n-4))%M;
    if(moze(kraj,poc,poc+1,poc+2))
        ret=(ret+resi(poc+3, kraj-1, n-4))%M;
    if(moze(kraj-1,kraj,poc,poc+1))
        ret=(ret+resi(poc+2, kraj-2, n-4))%M;
    if(moze(kraj-2,kraj-1,kraj,poc))
        ret=(ret+resi(poc+1, kraj-3, n-4))%M;
    return ret;
}

int Zvezda(int N, int* A) {
    N1=N;
    for(int i=0;i<=N;i++)
        a[i]=A[i];

    ll sol=0;
    for(int i=1;i<=N;i++)
    {
        if(moze(i,i+1,i+2,i+3))
        sol=(sol+resi(i+4, i-1 ,  N-4))%M;
    }
	return sol;
}