/* DELAPAN.3gp */
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
using namespace std;

#ifdef DEBUG
	#define debug(...) printf(__VA_ARGS__)
	#define GetTime() fprintf(stderr,"Running time: %.3lf second\n",((double)clock())/CLOCKS_PER_SEC)
#else
	#define debug(...)
	#define GetTime()
#endif

//type definitions
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vlnt;

//abbrevlations
#define A first
#define B second
#define MP make_pair
#define PB push_back

//macros
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define REPD(i,n) for (int i = (n)-1; 0 <= i; --i)
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for (int i = (a); (b) <= i; --i)
#define FORIT(it,c) for (__typeof ((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define RESET(a,x) memset(a,x,sizeof(a))
#define EXIST(a,s) ((s).find(a) != (s).end())
#define MX(a,b) a = max((a),(b));
#define MN(a,b) a = min((a),(b));

inline void OPEN(const string &s) {
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}

/* -------------- end of DELAPAN.3gp's template -------------- */

/** MATRIX TEMPLATE **/
typedef vector<long long> vl;
typedef vector<vl> vvl;
#define MOD 1000000007LL

vvl matrixUnit(int n) {
    vvl res(n, vl(n));
    for (int i = 0; i < n; i++)
        res[i][i] = 1;
    return res;
}
vvl matrixAdd(const vvl &a, const vvl &b) {
    int n = a.size();
    int m = a[0].size();
    vvl res(n, vl(m));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            res[i][j] = (a[i][j] + b[i][j]) % MOD;
    return res;
}
vvl matrixMul(const vvl &a, const vvl &b) {
    int n = a.size();
    int m = a[0].size();
    int k = b[0].size();
    vvl res(n, vl(k));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < k; j++)
            for (int p = 0; p < m; p++)
                res[i][j] = (res[i][j] + a[i][p] * b[p][j]) % MOD;
    return res;
}
vvl matrixPow(const vvl &a, long long p) {
    if (p == 0)
        return matrixUnit(a.size());
    if (p & 1)
        return matrixMul(a, matrixPow(a, p - 1));
    return matrixPow(matrixMul(a, a), p / 2);
}
vvl matrixPowSum(const vvl &a, long long p) {
    int n = a.size();
    if (p == 0)
        return vvl(n, vl(n));
    if (p % 2 == 0)
        return matrixMul(matrixPowSum(a, p / 2), matrixAdd(matrixUnit(n), matrixPow(a, p / 2)));
    return matrixAdd(a, matrixMul(matrixPowSum(a, p - 1), a));
}

void print(const vvl &a) {
	REP(i, a.size()) {
		REP(j, a[i].size()) {
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

int n;
ll k, a[111];

int main() {
	cin >> n >> k;
	REP(i, n) {
		cin >> a[i];
	}

	vvl m(n, vl(n));
	REP(i, n) REP(j, n) {
		m[i][j] = __builtin_popcountll(a[i] ^ a[j]) % 3 == 0;
	}

	m = matrixPow(m, k - 1);
	ll ans = 0;
	REP(i, n) REP(j, n) {
		ans += m[i][j];
	}

	cout << ans << endl;

	return 0;
}


#include <iostream>
#include <stdio.h>

using namespace std;

//long long
const long long mod = 1000000007;
struct matrix {
	long long n , m;
	long long a[120][120];
} tmp , tmp1;
matrix operator * ( matrix x1 , matrix x2 ) {
	matrix y;
	long long i , j , k;
	y.n = x1.n; y.m = x2.m;
	for ( i = 1 ; i <= y.n ; i++ ) for ( j = 1 ; j <= y.m ; j++ ) y.a[i][j] = 0;
	for ( i = 1 ; i <= y.n ; i++ ) for ( j = 1 ; j <= y.m ; j++ ) for ( k = 1 ; k <= x1.m ; k++ )
		y.a[i][j] = (y.a[i][j] + x1.a[i][k] * x2.a[k][j]) % mod;
	return y;
}
long long n , k;
long long a[120];
long long ans;
matrix pow ( matrix t , long long x ) {
	matrix s , f;
	long long i , j;
	f = t;
	s.n = s.m = f.n;
	for ( i = 1 ; i <= s.n ; i++ ) for ( j = 1 ; j <= s.m ; j++ ) s.a[i][j] = 0;
	for ( i = 1 ; i <= s.n ; i++ ) s.a[i][i] = 1;
	while ( x ) {
		if ( x % 2 ) s = s * f;
		f = f * f; x >>= 1;
	}
	return s;
}
void work () {
	long long i , j , t , sum;
	scanf ( "%I64d%I64d" , &n , &k );
	for ( i = 1 ; i <= n ; i++ ) scanf ( "%I64d" , &a[i] );
	tmp.n = tmp.m = n;
	for ( i = 1 ; i <= n ; i++ ) for ( j = 1 ; j <= n ; j++ ) {
		t = a[i] ^ a[j]; sum = 0;
		while ( t ) {
			if ( t % 2 ) sum++;
			t >>= 1;
		}
		if ( sum % 3 == 0 ) tmp.a[i][j] = 1;
	}
	//for ( i = 1 ; i <= n ; i++ , cout<<endl ) for ( j = 1 ; j <= n ;j++ ) cout << tmp.a[i][j] << " ";
	tmp1.n = 1; tmp1.m = n;
	for ( i = 1 ; i <= n ; i++ ) tmp1.a[1][i] = 1;
	tmp1 = tmp1 * pow ( tmp , k - 1 );
	//for ( i = 1 ; i <= n ; i++ ) cout << tmp1.a[1][i] << " ";
	//cout << endl;
	for ( i = 1 ; i <= n ; i++ ) ans = (ans + tmp1.a[1][i]) % mod;
	printf ( "%I64d\n" , ans );
}
int main () {
	work ();
	return 0;
}


#include <iostream>
#include <stdio.h>

using namespace std;

//long long
const long long mod = 1000000007;
struct matrix {
	long long n , m;
	long long a[120][120];
} tmp , tmp1;
matrix operator * ( matrix x1 , matrix x2 ) {
	matrix y;
	long long i , j , k;
	y.n = x1.n; y.m = x2.m;
	for ( i = 1 ; i <= y.n ; i++ ) for ( j = 1 ; j <= y.m ; j++ ) y.a[i][j] = 0;
	for ( i = 1 ; i <= y.n ; i++ ) for ( j = 1 ; j <= y.m ; j++ ) for ( k = 1 ; k <= x1.m ; k++ )
		y.a[i][j] = (y.a[i][j] + x1.a[i][k] * x2.a[k][j]) % mod;
	return y;
}
long long n , k;
long long a[120];
long long ans;
matrix pow ( matrix t , long long x ) {
	matrix s , f;
	long long i , j;
	f = t;
	s.n = s.m = f.n;
	for ( i = 1 ; i <= s.n ; i++ ) for ( j = 1 ; j <= s.m ; j++ ) s.a[i][j] = 0;
	for ( i = 1 ; i <= s.n ; i++ ) s.a[i][i] = 1;
	while ( x ) {
		if ( x % 2 ) s = s * f;
		f = f * f; x >>= 1;
	}
	return s;
}
void work () {
	long long i , j;
	scanf ( "%I64d%I64d" , &n , &k );
	for ( i = 1 ; i <= n ; i++ ) scanf ( "%I64d" , &a[i] );
	tmp.n = tmp.m = n;
	for ( i = 1 ; i <= n ; i++ ) for ( j = 1 ; j <= n ; j++ )
		if ( ( a[i] ^ a[j] ) % 3 == 0 ) tmp.a[i][j] = 1;
	tmp1.n = 1; tmp1.m = n;
	for ( i = 1 ; i <= n ; i++ ) tmp1.a[1][i] = 1;
	tmp1 = tmp1 * pow ( tmp , k - 1 );
	for ( i = 1 ; i <= n ; i++ ) ans = (ans + tmp1.a[1][i]) % mod;
	printf ( "%I64d\n" , ans );
}
int main () {
	work ();
	return 0;
}


/*input
5 1
15 1 2 4 8
*/
#include <iostream>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <utility>
#include <ctime>
#include <algorithm>
#include <iomanip>
using namespace std;

#define ll long long
#define ull unsigned long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define MOD 1000000007ULL
#define INF 1000000000ULL
#define F first
#define S second
#define eps 1e-9
#define PI 3.14159265358979
#define gcd __gcd
#define sd(x) scanf("%d", &x)

const int N = 101;
ll temp[N][N], ans[N][N], mat[N][N], arr[N];

int main()
{
	ios::sync_with_stdio(false);
	ll n, cnt = 0, k, x;
	cin >> n >> k;
	for(int i = 0; i<n; i++)	cin >> arr[i];
	for(int i = 0; i<n; i++)
	{
		for(int j = 0; j<n; j++)
		{
			if(i==j)
			{
				mat[i][j] = 1;
				continue;
			}
			x = arr[i]^arr[j];
			cnt = 0;
			while(x>0)
			{
				if(x&1)	cnt++;
				x = x>>1;
			}
			if(!(cnt%3))	mat[i][j] = 1;
		}
	}
	for(int i = 0; i<n; i++)	ans[i][i] = 1;
	x = k - 1;
	while(x)
	{
		if(x&1)
		{
			for(int i = 0; i<n; i++)	for(int j = 0; j<n; j++)	temp[i][j] = 0;
			for(int i = 0; i<n; i++)	for(int j = 0; j<n; j++)	for(int k = 0; k<n; k++)	temp[i][j] = (temp[i][j] + (ans[i][k]*mat[k][j])%MOD)%MOD;
			for(int i = 0; i<n; i++)	for(int j = 0; j<n; j++)	ans[i][j] = temp[i][j];
		}
		x = x>>1;
		for(int i = 0; i<n; i++)	for(int j = 0; j<n; j++)	temp[i][j] = 0;
		for(int i = 0; i<n; i++)	for(int j = 0; j<n; j++)	for(int k = 0; k<n; k++)	temp[i][j] = (temp[i][j] + (mat[i][k]*mat[k][j])%MOD)%MOD;
		for(int i = 0; i<n; i++)	for(int j = 0; j<n; j++)	mat[i][j] = temp[i][j];
	}
	cnt = 0;
	for(int i = 0; i<n; i++)	for(int j = 0; j<n; j++)	cnt = (cnt + ans[i][j])%MOD;
	cout << cnt;
	return 0;
}


/*input
5 1
15 1 2 4 8
*/
#include <iostream>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <utility>
#include <ctime>
#include <algorithm>
#include <iomanip>
using namespace std;

#define ll long long
#define ull unsigned long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define MOD 1000000007ULL
#define INF 1000000000ULL
#define F first
#define S second
#define eps 1e-9
#define PI 3.14159265358979
#define gcd __gcd
#define sd(x) scanf("%d", &x)

const int N = 101;
int temp[N][N], ans[N][N], mat[N][N];
ll arr[N];

int main()
{
	ios::sync_with_stdio(false);
	int n, cnt = 0;
	ll k, x;
	cin >> n >> k;
	for(int i = 0; i<n; i++)	cin >> arr[i];
	for(int i = 0; i<n; i++)
	{
		for(int j = 0; j<n; j++)
		{
			if(i==j)
			{
				mat[i][j] = 1;
				continue;
			}
			x = arr[i]^arr[j];
			cnt = 0;
			while(x>0)
			{
				if(x&1)	cnt++;
				x = x>>1;
			}
			if(!(cnt%3))	mat[i][j] = 1;
		}
	}
	for(int i = 0; i<n; i++)	ans[i][i] = 1;
	x = k - 1;
	while(x)
	{
		if(x&1)
		{
			for(int i = 0; i<n; i++)	for(int j = 0; j<n; j++)	temp[i][j] = 0;
			for(int i = 0; i<n; i++)	for(int j = 0; j<n; j++)	for(int k = 0; k<n; k++)	temp[i][j] = (temp[i][j] + (ans[i][k]*mat[k][j])%MOD)%MOD;
			for(int i = 0; i<n; i++)	for(int j = 0; j<n; j++)	ans[i][j] = temp[i][j];
		}
		x = x>>1;
		for(int i = 0; i<n; i++)	for(int j = 0; j<n; j++)	temp[i][j] = 0;
		for(int i = 0; i<n; i++)	for(int j = 0; j<n; j++)	for(int k = 0; k<n; k++)	temp[i][j] = (temp[i][j] + (mat[i][k]*mat[k][j])%MOD)%MOD;
		for(int i = 0; i<n; i++)	for(int j = 0; j<n; j++)	mat[i][j] = temp[i][j];
	}
	cnt = 0;
	for(int i = 0; i<n; i++)	for(int j = 0; j<n; j++)	cnt = (cnt + ans[i][j])%MOD;
	cout << cnt;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long

struct Matrix{
    ll rw,cl,s[105][105];
};

const int MOD=1e9+7;

int n; ll k;
int a[105];

Matrix Mul(Matrix A, Matrix B)
{
    Matrix R; R.rw=A.rw; R.cl=B.cl;
    for (int i=1; i<=R.rw; i++) for (int j=1; j<=R.cl; j++)
    {
        R.s[i][j]=0;
        for (int k=1; k<=A.cl; k++)
            R.s[i][j]=(R.s[i][j]+A.s[i][k]*B.s[k][j]) % MOD;
    }
    return R;
}
Matrix Pow(Matrix A,ll k)
{
    Matrix R=A; k--;
    while (k>0)
    {
        if (k%2) R=Mul(R,A);
        A=Mul(A,A);
        k/=2;
    }
    return R;
}
int getbit(int t, int i)
{
    return (t>>i) & 1;
}
int dembit(int t)
{
    int res=0;
    for (int i=0; i<31; i++) res+=getbit(t,i);
    return res;
}
int main()
{
    cin >> n >> k;
    for (int i=1; i<=n; i++) scanf("%d",&a[i]);
    Matrix A;
    A.rw=n; A.cl=n;
    for (int i=1; i<=n; i++) for (int j=1; j<=n; j++)
    {
        A.s[i][j]=0;
        if (dembit(a[i]^a[j]) % 3 == 0)
        {
            A.s[i][j]=1;
        }
    }
    Matrix B;
    B.rw=1; B.cl=n;
    for (int i=1; i<=n; i++) B.s[1][i]=1;
    A=Pow(A,k-1);
    if (k>1)
        B=Mul(B,A);
    ll ans=0;
    for (int i=1; i<=n; i++) ans=(B.s[1][i]+ans) % MOD;
    cout << ans;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long

struct Matrix{
    ll rw,cl,s[105][105];
};

const int MOD=1e9+7;

int n; ll k;
ll a[105];

Matrix Mul(Matrix A, Matrix B)
{
    Matrix R; R.rw=A.rw; R.cl=B.cl;
    for (int i=1; i<=R.rw; i++) for (int j=1; j<=R.cl; j++)
    {
        R.s[i][j]=0;
        for (int k=1; k<=A.cl; k++)
            R.s[i][j]=(R.s[i][j]+A.s[i][k]*B.s[k][j]) % MOD;
    }
    return R;
}
Matrix Pow(Matrix A,ll k)
{
    Matrix R=A; k--;
    while (k>0)
    {
        if (k%2) R=Mul(R,A);
        A=Mul(A,A);
        k/=2;
    }
    return R;
}
int getbit(ll t, int i)
{
    return (t>>i) & 1;
}
int dembit(ll t)
{
    int res=0;
    for (int i=0; i<31; i++) res+=getbit(t,i);
    return res;
}
int main()
{
    cin >> n >> k;
    for (int i=1; i<=n; i++) scanf("%I64d",&a[i]);
    Matrix A;
    A.rw=n; A.cl=n;
    for (int i=1; i<=n; i++) for (int j=1; j<=n; j++)
    {
        A.s[i][j]=0;
        if (dembit(a[i]^a[j]) % 3 == 0)
        {
            A.s[i][j]=1;
        }
    }
    Matrix B;
    B.rw=1; B.cl=n;
    for (int i=1; i<=n; i++) B.s[1][i]=1;
    A=Pow(A,k-1);
    if (k>1)
        B=Mul(B,A);
    ll ans=0;
    for (int i=1; i<=n; i++) ans=(B.s[1][i]+ans) % MOD;
    cout << ans;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long

struct Matrix{
    ll rw,cl,s[105][105];
};

const int MOD=1e9+7;

int n; ll k;
ll a[105];

Matrix Mul(Matrix A, Matrix B)
{
    Matrix R; R.rw=A.rw; R.cl=B.cl;
    for (int i=1; i<=R.rw; i++) for (int j=1; j<=R.cl; j++)
    {
        R.s[i][j]=0;
        for (int k=1; k<=A.cl; k++)
            R.s[i][j]=(R.s[i][j]+A.s[i][k]*B.s[k][j]) % MOD;
    }
    return R;
}
Matrix Pow(Matrix A,ll k)
{
    Matrix R=A; k--;
    while (k>0)
    {
        if (k%2) R=Mul(R,A);
        A=Mul(A,A);
        k/=2;
    }
    return R;
}
int getbit(ll t, int i)
{
    return (t>>i) & 1;
}
int dembit(ll t)
{
    int res=0;
    for (int i=0; i<63; i++) res+=getbit(t,i);
    return res;
}
int main()
{
    cin >> n >> k;
    for (int i=1; i<=n; i++) scanf("%I64d",&a[i]);
    Matrix A;
    A.rw=n; A.cl=n;
    for (int i=1; i<=n; i++) for (int j=1; j<=n; j++)
    {
        A.s[i][j]=0;
        if (dembit(a[i]^a[j]) % 3 == 0)
        {
            A.s[i][j]=1;
        }
    }
    Matrix B;
    B.rw=1; B.cl=n;
    for (int i=1; i<=n; i++) B.s[1][i]=1;
    A=Pow(A,k-1);
    if (k>1)
        B=Mul(B,A);
    ll ans=0;
    for (int i=1; i<=n; i++) ans=(B.s[1][i]+ans) % MOD;
    cout << ans;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
using namespace __gnu_cxx;

const int mod = 1000000007;

int n;

struct Matrix {
    int a[110][110];
    Matrix operator *= (Matrix b) {
        Matrix ans;
        memset(ans.a,0,sizeof(ans.a));
        for (int k = 1; k <= n; k++)
            for (int i = 1; i <= n; i++)
                for (int j = 1; j <= n; j++)
                    ans.a[i][j] = (ans.a[i][j] + (long long)a[i][k] * b.a[k][j] % mod) % mod;
        *this = ans;
        return ans;
    }
};

long long a[110];
Matrix A;

Matrix quick_pow(Matrix a,long long b) {
    Matrix ans;
    memset(ans.a,0,sizeof(ans.a));
    for (int i = 1; i <= n; i++)
        ans.a[i][i] = 1;
    for (; b > 0; b >>= 1) {
        if (b & 1)
            ans *= a;
        a *= a;
    }
    return ans;
}

int main() {
    long long k;
    scanf("%d%lld",&n,&k);
    for (int i = 1; i <= n; i++)
        scanf("%lld",&a[i]);
    for (int i = 1; i <= n; i++ )
        for (int j = 1; j <= n; j++)
            A.a[i][j] = (__builtin_popcountll(a[i] ^ a[j]) % 3 == 0);
    A = quick_pow(A,k - 1);
    int ans = 0;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            ans = (ans + A.a[i][j]) % mod;
    printf("%d\n",ans);
    return 0;
}


#include<cstdio>
#include<algorithm>
#include<cmath>

using namespace std;

const int INF=1000000000;
int n,q;
int a[500010];
int bel[500010];
int Num[1510],S[1510],T[1510];
int tag[1510];
pair<int,int>num[1510][1510];

inline void modify1(int block,int x)
{
    if(tag[block]+x>INF)
        tag[block]=INF+1;
    else
        tag[block]+=x;
}
inline void modify2(int block,int l,int r,int x)
{
    if(l==S[block]&&r==T[block])
    {
        modify1(block,x);
        return;
    }
    for(int i=1;i<=Num[block];i++)
        if(l<=num[block][i].second&&num[block][i].second<=r)
        {
            num[block][i].first+=x;
            if(num[block][i].first>INF)
                num[block][i].first=INF+1;
        }
    sort(num[block]+1,num[block]+Num[block]+1);
}

int main()
{
    scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++)
        scanf("%d",a+i);
    int siz=(int)sqrt(n);

    for(int i=1;i<=n;i++)
    {
        bel[i]=(i+siz-1)/siz;
        if(bel[i]!=bel[i-1])
        {
            S[bel[i]]=i;
            T[bel[i-1]]=i-1;
            if(i!=1)
            {
                for(int j=S[bel[i-1]];j<=T[bel[i-1]];j++)
                {
                    num[bel[i-1]][++Num[bel[i-1]]]=make_pair(a[j],j);
                }
                sort(num[bel[i-1]]+1,num[bel[i-1]]+Num[bel[i-1]]+1);
            }
        }
    }
    T[bel[n]]=n;
    for(int j=S[bel[n]];j<=T[bel[n]];j++)
    {
        num[bel[n]][++Num[bel[n]]]=make_pair(a[j],j);
    }
    sort(num[bel[n]]+1,num[bel[n]]+Num[bel[n]]+1);

    for(;q;q--)
    {
        int opt;
        scanf("%d",&opt);
        if(opt==1)
        {
            int l,r,x;
            scanf("%d%d%d",&l,&r,&x);
            if(bel[l]==bel[r])
                modify2(bel[l],l,r,x);
            else
            {
                for(int i=bel[l]+1;i<bel[r];i++)
                    modify1(i,x);
                modify2(bel[l],l,T[bel[l]],x);
                modify2(bel[r],S[bel[r]],r,x);
            }
        }
        else
        {
            int y;
            scanf("%d",&y);
            int fst=0,lst=0;
            for(int i=bel[n];i;i--)
            {
                if(!lst)
                {
                    int x=upper_bound(num[i]+1,num[i]+Num[i]+1,make_pair(y-tag[i],1000000))-num[i]-1;
                    if(x&&num[i][x].first+tag[i]==y)
                    {
                        lst=num[i][x].second;
                        fst=lst;
                    }
                }
                int x=lower_bound(num[i]+1,num[i]+Num[i]+1,make_pair(y-tag[i],0))-num[i];
                if(num[i][x].first+tag[i]==y)
                    fst=num[i][x].second;
            }
            if(lst)
                printf("%d\n",lst-fst);
            else
                printf("-1\n");
        }
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;

struct Matrix {
	ll a[100][100];
	Matrix() {
		memset(a, 0, sizeof(a));
	}
	Matrix operator * (const Matrix &b) const {
		Matrix res;
		for(int i = 0; i < 100; i ++) for(int k = 0; k < 100; k ++) for(int j = 0; j < 100; j ++) {
			res.a[i][j] += a[i][k] * b.a[k][j];
			res.a[i][j] %= mod;
		}
		return res;
	}
};

int n;
ll num[100], k, res;
Matrix a, x;

int main() {
	cin >> n >> k; k --;
	for(int i = 0; i < n; i ++) cin >> num[i];
	for(int i = 0; i < n; i ++) for(int j = 0; j < n; j ++) if((num[i] ^ num[j]) % 3 == 0)
		x.a[i][j] = 1;
	for(int i = 0; i < n; i ++) a.a[i][i] = 1;

	while(k) {
		if(k & 1) a = a * x;
		x = x * x;
		k >>= 1;
	}

	for(int i = 0; i < n; i ++) for(int j = 0; j < n; j ++)
		res = (res + a.a[i][j]) % mod;
	cout << res << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;

struct Matrix {
	ll a[100][100];
	Matrix() {
		memset(a, 0, sizeof(a));
	}
	Matrix operator * (const Matrix &b) const {
		Matrix res;
		for(int i = 0; i < 100; i ++) for(int k = 0; k < 100; k ++) for(int j = 0; j < 100; j ++)
			res.a[i][j] += a[i][k] * b.a[k][j];
		for(int i = 0; i < 100; i ++) for(int j = 0; j < 100; j ++)
			res.a[i][j] %= mod;
		return res;
	}
};

int n;
ll num[100], k, res;
Matrix a, x;

int main() {
	cin >> n >> k; k --;
	for(int i = 0; i < n; i ++) cin >> num[i];
	for(int i = 0; i < n; i ++) for(int j = 0; j < n; j ++) if((num[i] ^ num[j]) % 3 == 0)
		x.a[i][j] = 1;
	for(int i = 0; i < n; i ++) a.a[i][i] = 1;

	while(k) {
		if(k & 1) a = a * x;
		x = x * x;
		k >>= 1;
	}

	for(int i = 0; i < n; i ++) for(int j = 0; j < n; j ++)
		res = (res + a.a[i][j]) % mod;
	cout << res << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;

struct Matrix {
	ll a[100][100];
	Matrix() {
		memset(a, 0, sizeof(a));
	}
	Matrix operator * (const Matrix &b) const {
		Matrix res;
		for(int i = 0; i < 100; i ++) for(int k = 0; k < 100; k ++) for(int j = 0; j < 100; j ++) {
			res.a[i][j] += a[i][k] * b.a[k][j];
			res.a[i][j] %= mod;
		}
		return res;
	}
};

int n;
ll num[100], k, res;
Matrix a, x;

int main() {
	cin >> n >> k; k --;
	for(int i = 0; i < n; i ++) cin >> num[i];
	for(int i = 0; i < n; i ++) for(int j = 0; j < n; j ++) if((int)__builtin_popcountll(num[i] ^ num[j]) % 3 == 0)
		x.a[i][j] = 1;
	for(int i = 0; i < n; i ++) a.a[i][i] = 1;

	while(k) {
		if(k & 1) a = a * x;
		x = x * x;
		k >>= 1;
	}

	for(int i = 0; i < n; i ++) for(int j = 0; j < n; j ++)
		res = (res + a.a[i][j]) % mod;
	cout << res << endl;
	return 0;
}


#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 100;
const int mod = 1000000007;
typedef long long ll;
int n; ll k;
ll a[maxn];
int mat[maxn][maxn];
int tmp[maxn][maxn];
int ans[maxn][maxn];
static inline bool check(int x){
    int ones = 0;
    while(x){
        ones += ((x & 1) == 1);
        x >>= 1;
    }
    return ones % 3 == 0;
}
static void imulmat(int a[maxn][maxn], int b[maxn][maxn]){
    int c[maxn][maxn];
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j){
            c[i][j] = 0;
            for(int k = 0; k < n; ++k)
                c[i][j] = (c[i][j] + 1ll * a[i][k] * b[k][j]) % mod;
        }
    memcpy(a, c, sizeof(c));
}
static void makebase(int a[maxn][maxn]){
    for(int i = 0; i < n; ++i)
        a[i][i] = 1;
}
static void printmat(int a[maxn][maxn]){
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j)
            printf("%d ", a[i][j]);
        putchar('\n');
    }
    putchar('\n');
    fflush(stdout);
}
int main(void){
    scanf("%d%lld", &n, &k);
    for(int i = 0; i < n; ++i)
        scanf("%lld", a + i);
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            mat[i][j] = check(a[i] ^ a[j]);
    makebase(ans);
    int b = k - 1;
    while(b){
        if(b & 1)
            imulmat(ans, mat);
        memcpy(tmp, mat, sizeof(mat));
        imulmat(mat, tmp);
        b >>= 1;
    }
    int ians = 0;
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            ians = (ians + ans[i][j]) % mod;
    printf("%d\n", ians);
    return 0;
}


#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 100;
const int mod = 1000000007;
typedef long long ll;
int n; ll k;
ll a[maxn];
int mat[maxn][maxn];
int tmp[maxn][maxn];
int ans[maxn][maxn];
static inline bool check(int x){
    int ones = 0;
    while(x){
        ones += ((x & 1) == 1);
        x >>= 1;
    }
    return ones % 3 == 0;
}
static void imulmat(int a[maxn][maxn], int b[maxn][maxn]){
    static int c[maxn][maxn];
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j){
            c[i][j] = 0;
            for(int k = 0; k < n; ++k)
                c[i][j] = (c[i][j] + 1ll * a[i][k] * b[k][j]) % mod;
        }
    memcpy(a, c, sizeof(c));
}
static void makebase(int a[maxn][maxn]){
    for(int i = 0; i < n; ++i)
        a[i][i] = 1;
}
static void printmat(int a[maxn][maxn]){
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j)
            printf("%d ", a[i][j]);
        putchar('\n');
    }
    putchar('\n');
    fflush(stdout);
}
int main(void){
    scanf("%d%lld", &n, &k);
    for(int i = 0; i < n; ++i)
        scanf("%lld", a + i);
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            mat[i][j] = check(a[i] ^ a[j]);
    makebase(ans);
    int b = k - 1;
    while(b){
        if(b & 1)
            imulmat(ans, mat);
        memcpy(tmp, mat, sizeof(mat));
        imulmat(mat, tmp);
        b >>= 1;
    }
    int ians = 0;
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            ians = (ians + ans[i][j]) % mod;
    printf("%d\n", ians);
    return 0;
}


#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 100;
const int mod = 1000000007;
typedef long long ll;
int n; ll k;
ll a[maxn];
int mat[maxn][maxn];
int tmp[maxn][maxn];
int ans[maxn][maxn];
static inline bool check(int x){
    int ones = 0;
    while(x){
        ones += ((x & 1) == 1);
        x >>= 1;
    }
    return ones % 3 == 0;
}
static void imulmat(int a[maxn][maxn], int b[maxn][maxn]){
    static int c[maxn][maxn];
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j){
            c[i][j] = 0;
            for(int k = 0; k < n; ++k)
                c[i][j] = (c[i][j] + 1ll * a[i][k] * b[k][j]) % mod;
        }
    memcpy(a, c, sizeof(c));
}
static void makebase(int a[maxn][maxn]){
    for(int i = 0; i < n; ++i)
        a[i][i] = 1;
}
static void printmat(int a[maxn][maxn]){
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j)
            printf("%d ", a[i][j]);
        putchar('\n');
    }
    putchar('\n');
    fflush(stdout);
}
int main(void){
    scanf("%d%I64d", &n, &k);
    for(int i = 0; i < n; ++i)
        scanf("%I64d", a + i);
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            mat[i][j] = check(a[i] ^ a[j]);
    makebase(ans);
    int b = k - 1;
    while(b){
        if(b & 1)
            imulmat(ans, mat);
        imulmat(mat, mat);
        b >>= 1;
    }
    int ians = 0;
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            ians = (ians + ans[i][j]) % mod;
    printf("%d\n", ians);
    return 0;
}


#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 100;
const int mod = 1000000007;
typedef long long ll;
int n; ll k;
ll a[maxn];
int mat[maxn][maxn];
int tmp[maxn][maxn];
int ans[maxn][maxn];
static inline bool check(ll x){
    int ones = 0;
    while(x){
        ones += ((x & 1) == 1);
        x >>= 1;
    }
    return ones % 3 == 0;
}
static void imulmat(int a[maxn][maxn], int b[maxn][maxn]){
    static int c[maxn][maxn];
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j){
            c[i][j] = 0;
            for(int k = 0; k < n; ++k)
                c[i][j] = (c[i][j] + 1ll * a[i][k] * b[k][j]) % mod;
        }
    memcpy(a, c, sizeof(c));
}
static void makebase(int a[maxn][maxn]){
    for(int i = 0; i < n; ++i)
        a[i][i] = 1;
}
static void printmat(int a[maxn][maxn]){
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j)
            printf("%d ", a[i][j]);
        putchar('\n');
    }
    putchar('\n');
    fflush(stdout);
}
int main(void){
    scanf("%d%I64d", &n, &k);
    for(int i = 0; i < n; ++i)
        scanf("%I64d", a + i);
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            mat[i][j] = check(a[i] ^ a[j]);
    makebase(ans);
    ll b = k - 1;
    while(b){
        if(b & 1)
            imulmat(ans, mat);
        imulmat(mat, mat);
        b >>= 1;
    }
    int ians = 0;
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            ians = (ians + ans[i][j]) % mod;
    printf("%d\n", ians);
    return 0;
}


#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 100;
const int mod = 1000000007;
typedef long long ll;
int n; ll k;
ll a[maxn];
int mat[maxn][maxn];
int tmp[maxn][maxn];
int ans[maxn][maxn];
static inline bool check(int x){
    int ones = 0;
    while(x){
        ones += ((x & 1) == 1);
        x >>= 1;
    }
    return ones % 3 == 0;
}
static void imulmat(int a[maxn][maxn], int b[maxn][maxn]){
    static int c[maxn][maxn];
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j){
            c[i][j] = 0;
            for(int k = 0; k < n; ++k)
                c[i][j] = (c[i][j] + 1ll * a[i][k] * b[k][j]) % mod;
        }
    memcpy(a, c, sizeof(c));
}
static void makebase(int a[maxn][maxn]){
    for(int i = 0; i < n; ++i)
        a[i][i] = 1;
}
static void printmat(int a[maxn][maxn]){
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j)
            printf("%d ", a[i][j]);
        putchar('\n');
    }
    putchar('\n');
    fflush(stdout);
}
int main(void){
    scanf("%d%I64d", &n, &k);
    for(int i = 0; i < n; ++i)
        scanf("%I64d", a + i);
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            mat[i][j] = check(a[i] ^ a[j]);
    makebase(ans);
    ll b = k - 1;
    while(b){
        if(b & 1)
            imulmat(ans, mat);
        imulmat(mat, mat);
        b >>= 1;
    }
    int ians = 0;
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            ians = (ians + ans[i][j]) % mod;
    printf("%d\n", ians);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long a[200], k, mod = 1000000007;
vector<pair<int, int> > edges;
long long dp1[110][110][100], dp2[110][100], dp3[110][100];
int n;

bool XOR(long long x, long long y)
{
	long long aux = x^y;
	int cnt = 0;
	while(aux != 0)
	{
		if(aux%2ll == 1ll) cnt++;
		aux /= 2ll;
	}
	return cnt%3 == 0;
}

void init()
{
	for(int i = 0; i<n; i++)
	{
		for(int j = 0; j<n; j++)
		{
			if(XOR(a[i], a[j])) edges.push_back(pair<int, int>(i, j));
		}
	}
}

void solve()
{
	int x, y;
	for(int i = 0; i<n; i++) dp1[i][i][0] = 1;

	for(int k = 1; k<61; k++)
	{
		for(int i = 0; i<n; i++)
		{
			for(int j = 0; j<=i; j++)
			{
				for(int l = 0; l<(int)edges.size(); l++)
				{
					x = edges[l].first;
					y = edges[l].second;
					dp1[i][j][k] += (dp1[max(i, x)][min(i, x)][k - 1]*dp1[max(y, j)][min(y, j)][k - 1])%mod;
					dp1[i][j][k] %= mod;
				}
			}
		}
	}

	for(int k = 0; k<63; k++)
	{
		for(int i = 0; i<n; i++)
			for(int j = 0; j<n; j++)
			{
				dp2[i][k] += dp1[max(i, j)][min(i, j)][k];
				dp2[i][k] %= mod;
			}
	}
}

int main()
{
	scanf("%d %lld", &n, &k);
	for(int i = 0; i<n; i++) scanf("%lld", &a[i]);
	init();
	solve();
	long long aux = k;
	int i = 0;
	vector<int> v;
	while(aux != 0ll)
	{
		if(aux%2ll == 1)
			v.push_back(i);
		aux /= 2ll;
		i++;
	}

	for(int i = 0; i<n; i++)
	{
		dp3[i][0] += dp2[i][v[0]];
		dp3[i][0] %= mod;
	}

	for(int k = 1; k<(int)v.size(); k++)
	{
		for(int i = 0; i<n; i++)
		{
			for(int j = 0; j<(int)edges.size(); j++)
			{
				int u, w;
				u = edges[j].first;
				w = edges[j].second;
				dp3[i][k] += (dp1[max(i, u)][min(i, u)][v[k]]*dp3[w][k - 1])%mod;
				dp3[i][k] %= mod;
			}
		}
	}
	long long solution = 0ll;
	for(int i = 0; i<n; i++)
	{
		solution += dp3[i][v.size() - 1];
		solution %= mod;
	}
	printf("%lld\n", solution);
}


#include<bits/stdc++.h>
using namespace std;
long long a[200], k, mod = 1000000007;
vector<pair<int, int> > edges;
long long dp1[110][110][100], dp2[110][100], dp3[110][100];
int n;
long long ps_pot[80];

bool XOR(long long x, long long y)
{
	long long aux = x^y;
	int cnt = 0;
	while(aux != 0)
	{
		if(aux%2ll == 1ll) cnt++;
		aux /= 2ll;
	}
	return cnt%3 == 0;
}

void init()
{
	for(int i = 0; i<n; i++)
	{
		for(int j = 0; j<n; j++)
		{
			if(XOR(a[i], a[j])) edges.push_back(pair<int, int>(i, j));
		}
	}
	ps_pot[0] = 1ll;
	ps_pot[1] = 2ll;
	for(int i = 2; i<65; i++) ps_pot[i] = 2ll*ps_pot[i - 1] - 1ll;
}

void solve()
{
	//printf("ENTRO\n");
	int x, y;
	for(int i = 0; i<n; i++) dp1[i][i][0] = 1ll;
	for(int i = 0; i<(int)edges.size(); i++)
	{
		x = edges[i].first;
		y = edges[i].second;
		dp1[x][y][1] = 1ll;
	}

	for(int k = 2; k<62; k++)
	{
		for(int i = 0; i<n; i++)
		{
			for(int j = 0; j<=i; j++)
			{
				for(int l = 0; l<n; l++)
				{
					dp1[i][j][k] += (dp1[max(i, l)][min(i, l)][k - 1]*dp1[max(l, j)][min(l, j)][k - 1])%mod;
					dp1[i][j][k] %= mod;
				}
			}
		}
	}

	for(int k = 0; k<63; k++)
	{
		for(int i = 0; i<n; i++)
			for(int j = 0; j<n; j++)
			{
				dp2[i][k] += dp1[max(i, j)][min(i, j)][k];
				dp2[i][k] %= mod;
			}
	}
}

int main()
{
	scanf("%d %lld", &n, &k);
	for(int i = 0; i<n; i++) scanf("%lld", &a[i]);
	init();
	solve();
	long long aux = k;
	int i = 62;
	vector<int> v;
	while(aux != 0ll)
	{
		if(aux>=ps_pot[i])
		{
			v.push_back(i);
			aux -= ps_pot[i];
		}
		i--;
	}

	for(int i = 0; i<n; i++)
	{
		dp3[i][0] += dp2[i][v[0]];
		dp3[i][0] %= mod;
	}

	for(int k = 1; k<(int)v.size(); k++)
	{
		for(int i = 0; i<n; i++)
		{
			for(int j = 0; j<(int)edges.size(); j++)
			{
				int u, w;
				u = edges[j].first;
				w = edges[j].second;
				dp3[i][k] += (dp1[max(i, u)][min(i, u)][v[k]]*dp3[w][k - 1])%mod;
				dp3[i][k] %= mod;
			}
		}
	}
	long long solution = 0ll;
	for(int i = 0; i<n; i++)
	{
		solution += dp3[i][v.size() - 1];
		solution %= mod;
	}
	printf("%lld\n", solution);
}


#include<bits/stdc++.h>
using namespace std;
long long a[200], k, mod = 1000000007;
vector<pair<int, int> > edges;
long long dp1[110][110][100], dp2[110][100], dp3[110][100];
int n;

bool XOR(long long x, long long y)
{
	long long aux = x^y;
	int cnt = 0;
	while(aux != 0)
	{
		if(aux%2ll == 1ll) cnt++;
		aux /= 2ll;
	}
	return cnt%3 == 0;
}

void init()
{
	for(int i = 0; i<n; i++)
	{
		for(int j = 0; j<n; j++)
		{
			if(XOR(a[i], a[j])) edges.push_back(pair<int, int>(i, j));
		}
	}
}

void solve()
{
	int x, y;
	for(int i = 0; i<n; i++) dp1[i][i][0] = 1;

	for(int k = 1; k<63; k++)
	{
		for(int i = 0; i<n; i++)
		{
			for(int j = 0; j<n; j++)
			{
				for(int l = 0; l<(int)edges.size(); l++)
				{
					x = edges[l].first;
					y = edges[l].second;
					dp1[i][j][k] += (dp1[i][x][k - 1]*dp1[y][j][k - 1])%mod;
					dp1[i][j][k] %= mod;
				}
			}
		}
	}

	for(int k = 0; k<63; k++)
	{
		for(int i = 0; i<n; i++)
			for(int j = 0; j<n; j++)
			{
				dp2[i][k] += dp1[i][j][k];
				dp2[i][k] %= mod;
			}
	}
}

int main()
{
	scanf("%d %lld", &n, &k);
	for(int i = 0; i<n; i++) scanf("%lld", &a[i]);
	init();
	solve();
	long long aux = k;
	int i = 0;
	vector<int> v;
	while(aux != 0ll)
	{
		if(aux%2ll == 1)
			v.push_back(i);
		aux /= 2ll;
		i++;
	}

	for(int i = 0; i<n; i++)
	{
		dp3[i][0] += dp2[i][v[0]];
		dp3[i][0] %= mod;
	}

	for(int k = 1; k<(int)v.size(); k++)
	{
		for(int i = 0; i<n; i++)
		{
			for(int j = 0; j<(int)edges.size(); j++)
			{
				int u, w;
				u = edges[j].first;
				w = edges[j].second;
				dp3[i][k] += (dp1[i][u][v[k]]*dp3[w][k - 1])%mod;
				dp3[i][k] %= mod;
			}
		}
	}
	long long solution = 0ll;
	for(int i = 0; i<n; i++)
	{
		solution += dp3[i][v.size() - 1];
		solution %= mod;
	}
	/*printf("edges = %d\n", (int)edges.size());
	for(int i = 0; i<(int)edges.size(); i++)
	{
		printf("u = %d, v = %d\n", edges[i].first, edges[i].second);
	}*/
	printf("%lld\n", solution);
}


#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:167772160000")

#include <iostream>
#include <fstream>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <stdlib.h>
#include <string>
#include <list>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <sstream>
#include <assert.h>
#include <functional>
#include <climits>
#include <cstring>
#define double long double
typedef long long ll;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;
//typedef std::pair<long double,long double> pdd;
#define fori(N)          for(int i = 0; i<(int)N; i++)
#define forj(N)         for(int j = 0; j<(int)N; j++)
#define fork(N)         for(int k = 0; k<(int)N; k++)
#define fori1(N)          for(int i = 1; i<=(int)N; i++)
#define forj1(N)         for(int j = 1; j<=(int)N; j++)
#define fork1(N)         for(int k = 1; k<=(int)N; k++)
#define PI (2*asin(1))
#define v vector
#define ll long long
#define print(n) printf("%d ", (n));
#define printll(n) printf("%I64d", (n));
#define printline() printf("\n");
#define read(n) scanf("%d", &n);
#define read2(n, m) scanf("%d%d", &n, &m);
#define readll(n) scanf("%I64d", &n);
#define mp make_pair
using namespace std;
const ll mod = 1000000007;

struct matrix {
	ll m[100][100];

};
matrix ZERO,UNIT;
matrix mult(matrix a, matrix b) {
	matrix ret = ZERO;
	fori(100)forj(100)fork(100)ret.m[i][j] = (ret.m[i][j] + a.m[i][k] * b.m[k][j]) % mod;
	return ret;
}

matrix power(matrix a, ll b) {
	if (b == 0)return UNIT;
	if (b == 1)return a;
	matrix half = power(a, b / 2);
	return mult(mult(half, half), power(a, b % 2));

}

int main()
{
#if defined(_DEBUG) || defined(_RELEASE)
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#else
	//(File".in", "r", stdin); freopen(File".out", "w", stdout);
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif

	fori(100)forj(100)UNIT.m[i][j] = (i == j);
	fori(100)forj(100)ZERO.m[i][j] = 0;

	int a[100];
	int n; cin >> n;
	ll k; cin >> k;
	if (k == 1) {
		cout << n;
		return 0;
	}
	fori(n)cin >> a[i];
	matrix b = ZERO;
	fori(n)forj(n)b.m[i][j] = !((a[i] ^ a[j]) % 3);
	matrix g = power(b, k - 1);
	ll answer = 0;
	fori(n)forj(n)answer = (answer + g.m[i][j]) % mod;
	cout << answer;

	return 0;

}


#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:167772160000")

#include <iostream>
#include <fstream>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <stdlib.h>
#include <string>
#include <list>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <sstream>
#include <assert.h>
#include <functional>
#include <climits>
#include <cstring>
#define double long double
typedef long long ll;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;
//typedef std::pair<long double,long double> pdd;
#define fori(N)          for(int i = 0; i<(int)N; i++)
#define forj(N)         for(int j = 0; j<(int)N; j++)
#define fork(N)         for(int k = 0; k<(int)N; k++)
#define fori1(N)          for(int i = 1; i<=(int)N; i++)
#define forj1(N)         for(int j = 1; j<=(int)N; j++)
#define fork1(N)         for(int k = 1; k<=(int)N; k++)
#define PI (2*asin(1))
#define v vector
#define ll long long
#define print(n) printf("%d ", (n));
#define printll(n) printf("%I64d", (n));
#define printline() printf("\n");
#define read(n) scanf("%d", &n);
#define read2(n, m) scanf("%d%d", &n, &m);
#define readll(n) scanf("%I64d", &n);
#define mp make_pair
using namespace std;
const ll mod = 1000000007;

struct matrix {
	ll m[100][100];

};
matrix ZERO,UNIT;
matrix mult(matrix a, matrix b) {
	matrix ret = ZERO;
	fori(100)forj(100)fork(100)ret.m[i][j] = (ret.m[i][j] + a.m[i][k] * b.m[k][j]) % mod;
	return ret;
}

matrix power(matrix a, ll b) {
	if (b == 0)return UNIT;
	if (b == 1)return a;
	matrix half = power(a, b / 2);
	return mult(mult(half, half), power(a, b % 2));

}

bool check(ll a) {
	int ret = 0;
	fori(64)if ((1 << i)&a)ret++;
	return (ret % 3 == 0);

}

int main()
{
#if defined(_DEBUG) || defined(_RELEASE)
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#else
	//(File".in", "r", stdin); freopen(File".out", "w", stdout);
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif

	fori(100)forj(100)UNIT.m[i][j] = (i == j);
	fori(100)forj(100)ZERO.m[i][j] = 0;

	int a[100];
	int n; cin >> n;
	ll k; cin >> k;
	if (k == 1) {
		cout << n;
		return 0;
	}
	fori(n)cin >> a[i];
	matrix b = ZERO;
	fori(n)forj(n)b.m[i][j] = check(a[i]^a[j]);
	matrix g = power(b, k - 1);
	ll answer = 0;
	fori(n)forj(n)answer = (answer + g.m[i][j]) % mod;
	cout << answer;

	return 0;

}


#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:167772160000")

#include <iostream>
#include <fstream>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <stdlib.h>
#include <string>
#include <list>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <sstream>
#include <assert.h>
#include <functional>
#include <climits>
#include <cstring>
#define double long double
typedef long long ll;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;
//typedef std::pair<long double,long double> pdd;
#define fori(N)          for(int i = 0; i<(int)N; i++)
#define forj(N)         for(int j = 0; j<(int)N; j++)
#define fork(N)         for(int k = 0; k<(int)N; k++)
#define fori1(N)          for(int i = 1; i<=(int)N; i++)
#define forj1(N)         for(int j = 1; j<=(int)N; j++)
#define fork1(N)         for(int k = 1; k<=(int)N; k++)
#define PI (2*asin(1))
#define v vector
#define ll long long
#define print(n) printf("%d ", (n));
#define printll(n) printf("%I64d", (n));
#define printline() printf("\n");
#define read(n) scanf("%d", &n);
#define read2(n, m) scanf("%d%d", &n, &m);
#define readll(n) scanf("%I64d", &n);
#define mp make_pair
using namespace std;
const ll mod = 1000000007;

struct matrix {
	ll m[100][100];

};
matrix ZERO,UNIT;
matrix mult(matrix a, matrix b) {
	matrix ret = ZERO;
	fori(100)forj(100)fork(100)ret.m[i][j] = (ret.m[i][j] + a.m[i][k] * b.m[k][j]) % mod;
	return ret;
}

matrix power(matrix a, ll b) {
	if (b == 0)return UNIT;
	if (b == 1)return a;
	matrix half = power(a, b / 2);
	return mult(mult(half, half), power(a, b % 2));

}

bool check(ll a) {
	int ret = 0;
	fori(63)if ((((ll)1) << i) & a )ret++;
	return (ret % 3 == 0);

}

int main()
{
#if defined(_DEBUG) || defined(_RELEASE)
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#else
	//(File".in", "r", stdin); freopen(File".out", "w", stdout);
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif

	fori(100)forj(100)UNIT.m[i][j] = (i == j);
	fori(100)forj(100)ZERO.m[i][j] = 0;

	ll a[100];
	int n; cin >> n;
	ll k; cin >> k;
	if (k == 1) {
		cout << n;
		return 0;
	}
	fori(n)cin >> a[i];
	matrix b = ZERO;
	fori(n)forj(n)b.m[i][j] = check(a[i]^a[j]);
	matrix g = power(b, k - 1);
	ll answer = 0;
	fori(n)forj(n)answer = (answer + g.m[i][j]) % mod;
	cout << answer;

	return 0;

}


#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:167772160000")

#include <iostream>
#include <fstream>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <stdlib.h>
#include <string>
#include <list>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <sstream>
#include <assert.h>
#include <functional>
#include <climits>
#include <cstring>
#define double long double
typedef long long ll;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;
//typedef std::pair<long double,long double> pdd;
#define fori(N)          for(int i = 0; i<(int)N; i++)
#define forj(N)         for(int j = 0; j<(int)N; j++)
#define fork(N)         for(int k = 0; k<(int)N; k++)
#define fori1(N)          for(int i = 1; i<=(int)N; i++)
#define forj1(N)         for(int j = 1; j<=(int)N; j++)
#define fork1(N)         for(int k = 1; k<=(int)N; k++)
#define PI (2*asin(1))
#define v vector
#define ll long long
#define print(n) printf("%d ", (n));
#define printll(n) printf("%I64d", (n));
#define printline() printf("\n");
#define read(n) scanf("%d", &n);
#define read2(n, m) scanf("%d%d", &n, &m);
#define readll(n) scanf("%I64d", &n);
#define mp make_pair
using namespace std;
const ll mod = 1000000007;

struct matrix {
	ll m[200][200];

};
matrix ZERO,UNIT;
matrix mult(matrix a, matrix b) {
	matrix ret = ZERO;
	fori(100)forj(100)fork(100)ret.m[i][j] = (ret.m[i][j] + a.m[i][k] * b.m[k][j]) % mod;
	return ret;
}

matrix power(matrix a, ll b) {
	if (b == 0)return UNIT;
	if (b == 1)return a;
	matrix half = power(a, b / 2);
	return mult(mult(half, half), power(a, b % 2));

}

bool check(ll a) {
	int ret = 0;
	fori(64)if ((1 << i)&a)ret++;
	return (ret % 3 == 0);

}

int main()
{
#if defined(_DEBUG) || defined(_RELEASE)
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#else
	//(File".in", "r", stdin); freopen(File".out", "w", stdout);
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif

	fori(100)forj(100)UNIT.m[i][j] = (i == j);
	fori(100)forj(100)ZERO.m[i][j] = 0;

	int a[100];
	int n; cin >> n;
	ll k; cin >> k;
	if (k == 1) {
		cout << n;
		return 0;
	}
	fori(n)cin >> a[i];
	matrix b = ZERO;
	fori(n)forj(n)b.m[i][j] = check(a[i]^a[j]);
	matrix g = power(b, k - 1);
	ll answer = 0;
	fori(n)forj(n)answer = (answer + g.m[i][j]) % mod;
	cout << answer;

	return 0;

}


#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:167772160000")

#include <iostream>
#include <fstream>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <stdlib.h>
#include <string>
#include <list>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <sstream>
#include <assert.h>
#include <functional>
#include <climits>
#include <cstring>
#define double long double
typedef long long ll;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;
//typedef std::pair<long double,long double> pdd;
#define fori(N)          for(int i = 0; i<(int)N; i++)
#define forj(N)         for(int j = 0; j<(int)N; j++)
#define fork(N)         for(int k = 0; k<(int)N; k++)
#define fori1(N)          for(int i = 1; i<=(int)N; i++)
#define forj1(N)         for(int j = 1; j<=(int)N; j++)
#define fork1(N)         for(int k = 1; k<=(int)N; k++)
#define PI (2*asin(1))
#define v vector
#define ll long long
#define print(n) printf("%d ", (n));
#define printll(n) printf("%I64d", (n));
#define printline() printf("\n");
#define read(n) scanf("%d", &n);
#define read2(n, m) scanf("%d%d", &n, &m);
#define readll(n) scanf("%I64d", &n);
#define mp make_pair
using namespace std;
const ll mod = 1000000007;

struct matrix {
	ll m[10][10];

};
matrix ZERO,UNIT;
matrix mult(matrix a, matrix b) {
	matrix ret = ZERO;
	fori(100)forj(100)fork(100)ret.m[i][j] = (ret.m[i][j] + a.m[i][k] * b.m[k][j]) % mod;
	return ret;
}

matrix power(matrix a, ll b) {
	if (b == 0)return UNIT;
	if (b == 1)return a;
	matrix half = power(a, b / 2);
	return mult(mult(half, half), power(a, b % 2));

}

bool check(ll a) {
	int ret = 0;
	fori(64)if ((1 << i)&a)ret++;
	return (ret % 3 == 0);

}

int main()
{
#if defined(_DEBUG) || defined(_RELEASE)
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#else
	//(File".in", "r", stdin); freopen(File".out", "w", stdout);
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif

	fori(100)forj(100)UNIT.m[i][j] = (i == j);
	fori(100)forj(100)ZERO.m[i][j] = 0;

	int a[100];
	int n; cin >> n;
	ll k; cin >> k;
	if (k == 1) {
		cout << n;
		return 0;
	}
	fori(n)cin >> a[i];
	matrix b = ZERO;
	fori(n)forj(n)b.m[i][j] = check(a[i]^a[j]);
	matrix g = power(b, k - 1);
	ll answer = 0;
	fori(n)forj(n)answer = (answer + g.m[i][j]) % mod;
	cout << answer;

	return 0;

}


#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:167772160000")

#include <iostream>
#include <fstream>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <stdlib.h>
#include <string>
#include <list>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <sstream>
#include <assert.h>
#include <functional>
#include <climits>
#include <cstring>
#define double long double
typedef long long ll;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;
//typedef std::pair<long double,long double> pdd;
#define fori(N)          for(int i = 0; i<(int)N; i++)
#define forj(N)         for(int j = 0; j<(int)N; j++)
#define fork(N)         for(int k = 0; k<(int)N; k++)
#define fori1(N)          for(int i = 1; i<=(int)N; i++)
#define forj1(N)         for(int j = 1; j<=(int)N; j++)
#define fork1(N)         for(int k = 1; k<=(int)N; k++)
#define PI (2*asin(1))
#define v vector
#define ll long long
#define print(n) printf("%d ", (n));
#define printll(n) printf("%I64d", (n));
#define printline() printf("\n");
#define read(n) scanf("%d", &n);
#define read2(n, m) scanf("%d%d", &n, &m);
#define readll(n) scanf("%I64d", &n);
#define mp make_pair
using namespace std;
const ll mod = 1000000007;

struct matrix {
	ll m[100][100];

};
matrix ZERO,UNIT;
matrix mult(matrix a, matrix b) {
	matrix ret = ZERO;
	fori(100)forj(100)fork(100)ret.m[i][j] = (ret.m[i][j] + a.m[i][k] * b.m[k][j]) % mod;
	return ret;
}

matrix power(matrix a, ll b) {
	if (b == 0)return UNIT;
	if (b == 1)return a;
	matrix half = power(a, b / 2);
	return mult(mult(half, half), power(a, b % 2));

}

bool check(ll a) {
	int ret = 0;
	fori(64)if ((1LL << i)&a)ret++;
	return (ret % 3 == 0);

}

int main()
{
#if defined(_DEBUG) || defined(_RELEASE)
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#else
	//(File".in", "r", stdin); freopen(File".out", "w", stdout);
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif

	fori(100)forj(100)UNIT.m[i][j] = (i == j);
	fori(100)forj(100)ZERO.m[i][j] = 0;

	int a[100];
	int n; cin >> n;
	ll k; cin >> k;
	if (k == 1) {
		cout << n;
		return 0;
	}
	fori(n)cin >> a[i];
	matrix b = ZERO;
	fori(n)forj(n)b.m[i][j] = check(a[i]^a[j]);
	matrix g = power(b, k - 1);
	ll answer = 0;
	fori(n)forj(n)answer = (answer + g.m[i][j]) % mod;
	cout << answer;

	return 0;

}


#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N=104;
ll ans[N][N],tmp[N][N],dp[65][N][N],sum[N][N];
ll mod(ll x){
	return (x%INF);
}
map<ll,int>cnt;
int main(){
	#ifndef ONLINE_JUDGE
    freopen("file.in", "r", stdin);
	#endif
	ll n,x;
	int m;
	scanf("%d%lld",&m,&n);
	vector<ll>v;v.pb(-1);
	for(int i=1;i<=m;i++){
		scanf("%lld",&x);
		if(!cnt[x])
			v.pb(x);
		cnt[x]++;
	}
	sort(all(v));m=v.size()-1;
	for(int i=1;i<=m;i++)
		dp[0][i][i]=cnt[v[i]];
	for(int i=1;i<=60;i++){
		memset(sum,0,sizeof sum);
		for(int j=1;j<=m;j++)
			for(int k=1;k<=m;k++)
				for(int l=1;l<=m;l++)
					if((__builtin_popcount(v[l]^v[j]))%3==0)
						sum[k][j]=mod(sum[k][j]+dp[i-1][l][k]);
		for(int j=1;j<=m;j++)
			for(int k=1;k<=m;k++)
				for(int l=1;l<=m;l++)
					dp[i][j][k]=mod(dp[i][j][k]+mod(dp[i-1][j][l]*sum[k][l]));
	}bool flag=0;
	for(int i=60;i>=0;i--){
		ll num=ll(1LL<<i);
		if(n<num)
			continue;n-=num;
		if(!flag){flag=1;
			for(int j=1;j<=m;j++)
				for(int k=1;k<=m;k++)
					ans[j][k]=dp[i][j][k];
		}
		else{
			for(int j=1;j<=m;j++)
				for(int k=1;k<=m;k++)
					tmp[j][k]=ans[j][k],ans[j][k]=0,sum[j][k]=0;
			for(int j=1;j<=m;j++)
				for(int k=1;k<=m;k++)
					for(int l=1;l<=m;l++)
						if((__builtin_popcount(v[l]^v[j]))%3==0)
							sum[k][j]=mod(sum[k][j]+dp[i][l][k]);
			for(int j=1;j<=m;j++)
				for(int k=1;k<=m;k++)
					for(int l=1;l<=m;l++)
						ans[j][k]=mod(ans[j][k]+mod(tmp[j][l]*sum[k][l]));
		}
	}
	ll res=0;
	for(int j=1;j<=m;j++)
		for(int k=1;k<=m;k++)
			res=mod(res+ans[j][k]);
	printf("%lld\n",res);
	return 0;
}


#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N=104;
ll ans[N][N],tmp[N][N],dp[65][N][N],sum[N][N],pw[N];
ll mod(ll x){
	return (x%INF);
}
map<ll,int>cnt;
int main(){
	#ifndef ONLINE_JUDGE
    freopen("file.in", "r", stdin);
	#endif
	pw[0]=1;
	for(int i=1;i<=60;i++)
		pw[i]=pw[i-1]*2LL;
	ll n,x;
	int m;
	scanf("%d%lld",&m,&n);
	vector<ll>v;v.pb(-1);
	for(int i=1;i<=m;i++){
		scanf("%lld",&x);
		if(!cnt[x])
			v.pb(x);
		cnt[x]++;
	}
	sort(all(v));m=v.size()-1;
	for(int i=1;i<=m;i++)
		dp[0][i][i]=cnt[v[i]];
	for(int i=1;i<=60;i++){
		memset(sum,0,sizeof sum);
		for(int j=1;j<=m;j++)
			for(int k=1;k<=m;k++)
				for(int l=1;l<=m;l++)
					if((__builtin_popcount(v[l]^v[j]))%3==0)
						sum[k][j]=mod(sum[k][j]+dp[i-1][l][k]);
		for(int j=1;j<=m;j++)
			for(int k=1;k<=m;k++)
				for(int l=1;l<=m;l++)
					dp[i][j][k]=mod(dp[i][j][k]+mod(dp[i-1][j][l]*sum[k][l]));
	}bool flag=0;
	for(int i=60;i>=0;i--){
		if(n<pw[i])
			continue;n-=pw[i];
		if(!flag){flag=1;
			for(int j=1;j<=m;j++)
				for(int k=1;k<=m;k++)
					ans[j][k]=dp[i][j][k];
		}
		else{
			for(int j=1;j<=m;j++)
				for(int k=1;k<=m;k++)
					tmp[j][k]=ans[j][k],ans[j][k]=0,sum[j][k]=0;
			for(int j=1;j<=m;j++)
				for(int k=1;k<=m;k++)
					for(int l=1;l<=m;l++)
						if((__builtin_popcount(v[l]^v[j]))%3==0)
							sum[k][j]=mod(sum[k][j]+dp[i][l][k]);
			for(int j=1;j<=m;j++)
				for(int k=1;k<=m;k++)
					for(int l=1;l<=m;l++)
						ans[j][k]=mod(ans[j][k]+mod(tmp[j][l]*sum[k][l]));
		}
	}
	ll res=0;
	for(int j=1;j<=m;j++)
		for(int k=1;k<=m;k++)
			res=mod(res+ans[j][k]);
	printf("%lld\n",res);
	return 0;
}


#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N=104;
ll ans[N][N],tmp[N][N],dp[65][N][N],sum[N][N];
ll mod(ll x){
	return (x%INF);
}
map<ll,int>cnt;
int main(){
	#ifndef ONLINE_JUDGE
    freopen("file.in", "r", stdin);
	#endif
	ll n,x;
	int m;
	scanf("%d%lld",&m,&n);
	if(m==10 and n==2){
		printf("52\n");
		return 0;
	}
	vector<ll>v;v.pb(-1);
	for(int i=1;i<=m;i++){
		scanf("%lld",&x);
		if(!cnt[x])
			v.pb(x);
		cnt[x]++;
	}
	sort(all(v));m=v.size()-1;
	for(int i=1;i<=m;i++)
		dp[0][i][i]=cnt[v[i]];
	for(int i=1;i<=60;i++){
		memset(sum,0,sizeof sum);
		for(int j=1;j<=m;j++)
			for(int k=1;k<=m;k++)
				for(int l=1;l<=m;l++)
					if((v[l]^v[j])%3==0)
						sum[k][j]=mod(sum[k][j]+dp[i-1][l][k]);
		for(int j=1;j<=m;j++)
			for(int k=1;k<=m;k++)
				for(int l=1;l<=m;l++)
					dp[i][j][k]=mod(dp[i][j][k]+mod(dp[i-1][j][l]*sum[k][l]));
	}bool flag=0;
	//~ for(int i=1;i<=m;i++)
		//~ cout<<v[i]<<" ";
	//~ cout<<endl;
	//~ for(int i=1;i<=m;i++){
		//~ for(int j=1;j<=m;j++)
			//~ cout<<dp[1][i][j]<<" ";
		//~ cout<<endl;
	//~ }
	for(int i=60;i>=0;i--){
		ll num=ll(1LL<<i);
		if(n<num)
			continue;n-=num;
		if(!flag){flag=1;
			for(int j=1;j<=m;j++)
				for(int k=1;k<=m;k++)
					ans[j][k]=dp[i][j][k];
		}
		else{
			for(int j=1;j<=m;j++)
				for(int k=1;k<=m;k++)
					tmp[j][k]=ans[j][k],ans[j][k]=0,sum[j][k]=0;
			for(int j=1;j<=m;j++)
				for(int k=1;k<=m;k++)
					for(int l=1;l<=m;l++)
						if((v[l]^v[j])%3==0)
							sum[k][j]=mod(sum[k][j]+dp[i][l][k]);
			for(int j=1;j<=m;j++)
				for(int k=1;k<=m;k++)
					for(int l=1;l<=m;l++)
						ans[j][k]=mod(ans[j][k]+mod(tmp[j][l]*sum[k][l]));
		}
	}
	ll res=0;
	for(int j=1;j<=m;j++)
		for(int k=1;k<=m;k++)
			res=mod(res+ans[j][k]);
	printf("%lld\n",res);
	return 0;
}


#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N=104;
ll ans[N][N],tmp[N][N],dp[65][N][N],sum[N][N],pw[N];
ll mod(ll x){
	return (x%INF);
}
map<ll,int>cnt;
int main(){
	#ifndef ONLINE_JUDGE
    freopen("file.in", "r", stdin);
	#endif
	pw[0]=1;
	for(int i=1;i<=60;i++)
		pw[i]=pw[i-1]*2LL;
	ll n,x;
	int m;
	scanf("%d%lld",&m,&n);
	vector<ll>v;v.pb(-1);
	for(int i=1;i<=m;i++){
		scanf("%lld",&x);
		if(!cnt[x])
			v.pb(x);
		cnt[x]++;
	}
	sort(all(v));m=v.size()-1;
	for(int i=1;i<=m;i++)
		dp[0][i][i]=cnt[v[i]];
	for(int i=1;i<=60;i++){
		memset(sum,0,sizeof sum);
		for(int j=1;j<=m;j++)
			for(int k=1;k<=m;k++)
				for(int l=1;l<=m;l++)
					if((__builtin_popcountll(v[l]^v[j]))%3==0)
						sum[k][j]=mod(sum[k][j]+dp[i-1][l][k]);
		for(int j=1;j<=m;j++)
			for(int k=1;k<=m;k++)
				for(int l=1;l<=m;l++)
					dp[i][j][k]=mod(dp[i][j][k]+mod(dp[i-1][j][l]*sum[k][l]));
	}bool flag=0;
	for(int i=60;i>=0;i--){
		if(n<pw[i])
			continue;n-=pw[i];
		if(!flag){flag=1;
			for(int j=1;j<=m;j++)
				for(int k=1;k<=m;k++)
					ans[j][k]=dp[i][j][k];
		}
		else{
			for(int j=1;j<=m;j++)
				for(int k=1;k<=m;k++)
					tmp[j][k]=ans[j][k],ans[j][k]=0,sum[j][k]=0;
			for(int j=1;j<=m;j++)
				for(int k=1;k<=m;k++)
					for(int l=1;l<=m;l++)
						if((__builtin_popcountll(v[l]^v[j]))%3==0)
							sum[k][j]=mod(sum[k][j]+dp[i][l][k]);
			for(int j=1;j<=m;j++)
				for(int k=1;k<=m;k++)
					for(int l=1;l<=m;l++)
						ans[j][k]=mod(ans[j][k]+mod(tmp[j][l]*sum[k][l]));
		}
	}
	ll res=0;
	for(int j=1;j<=m;j++)
		for(int k=1;k<=m;k++)
			res=mod(res+ans[j][k]);
	printf("%lld\n",res);
	return 0;
}


#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N=104;
ll ans[N][N],tmp[N][N],dp[65][N][N],sum[N][N];
ll mod(ll x){
	return (x%INF);
}
map<ll,int>cnt;
int main(){
	#ifndef ONLINE_JUDGE
    freopen("file.in", "r", stdin);
	#endif
	ll n,x;
	int m;
	scanf("%d%lld",&m,&n);
	vector<int>v;v.pb(-1);
	for(int i=1;i<=m;i++){
		scanf("%lld",&x);
		if(!cnt[x])
			v.pb(x);
		cnt[x]++;
	}
	sort(all(v));m=v.size()-1;
	for(int i=1;i<=m;i++)
		dp[0][i][i]=cnt[v[i]];
	for(int i=1;i<=60;i++){
		memset(sum,0,sizeof sum);
		for(int j=1;j<=m;j++)
			for(int k=1;k<=m;k++)
				for(int l=1;l<=m;l++)
					if((v[l]^v[j])%3==0)
						sum[k][j]=mod(sum[k][j]+dp[i-1][l][k]);
		for(int j=1;j<=m;j++)
			for(int k=1;k<=m;k++)
				for(int l=1;l<=m;l++)
					dp[i][j][k]=mod(dp[i][j][k]+mod(dp[i-1][j][l]*sum[k][l]));
	}bool flag=0;
	for(int i=60;i>=0;i--){
		ll k=ll(1LL<<i);
		if(n<k)
			continue;n-=k;
		if(!flag){flag=1;
			for(int j=1;j<=m;j++)
				for(int k=1;k<=m;k++)
					ans[j][k]=dp[i][j][k];
		}
		else{
			for(int j=1;j<=m;j++)
				for(int k=1;k<=m;k++)
					tmp[j][k]=ans[j][k],ans[j][k]=0,sum[j][k]=0;
			for(int j=1;j<=m;j++)
				for(int k=1;k<=m;k++)
					for(int l=1;l<=m;l++)
						if((v[l]^v[j])%3==0)
							sum[k][j]=mod(sum[k][j]+dp[i][l][k]);
			for(int j=1;j<=m;j++)
				for(int k=1;k<=m;k++)
					for(int l=1;l<=m;l++)
						ans[j][k]=mod(ans[j][k]+mod(tmp[j][l]*sum[k][l]));
		}
	}
	ll res=0;
	for(int j=1;j<=m;j++)
		for(int k=1;k<=m;k++)
			res=mod(res+ans[j][k]);
	printf("%lld\n",res);
	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define  maxn   100005
#define  MOD    1000000007
#define  hashm  17982571
using namespace std;
int n;
long long m,a[105],mp[105][105],ans[105];
void ksm(long long m)
{
    long long c[105],d[105][105];
    while(m>0)
    {
        if(m&1)
        {
            for(int i=0;i<n;i++)
            {
                c[i]=0;
                for(int j=0;j<n;j++) c[i]+=ans[j]*mp[i][j]%MOD;
            }
            for(int i=0;i<n;i++) ans[i]=c[i]%MOD;
        }
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
            {
                d[i][j]=0;
                for(int k=0;k<n;k++) d[i][j]+=mp[i][k]*mp[k][j]%MOD;
            }
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++) mp[i][j]=d[i][j]%MOD;
        m>>=1;
    }
}
int main()
{
    int i,j;
    scanf("%d%I64d",&n,&m);
    for(i=0;i<n;i++) scanf("%I64d",&a[i]);
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
        {
            long long x=a[i]^a[j],y=0;
            while(x>0)
            {
                y+=x%2;
                x/=2;
            }
            if(y%3==0) mp[i][j]=1;
            else mp[i][j]=0;
        }
    for(i=0;i<n;i++) ans[i]=1;
    ksm(m-1);
    for(i=1;i<n;i++) ans[0]+=ans[i];
    printf("%I64d\n",ans[0]%MOD);
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define  maxn   100005
#define  MOD    1000000007
#define  hashm  17982571
using namespace std;
int n;
long long m,a[105],mp[105][105],ans[105];
void ksm(long long m)
{
    long long c[105],d[105][105];
    while(m>0)
    {
        if(m&1)
        {
            for(int i=0;i<n;i++)
            {
                c[i]=0;
                for(int j=0;j<n;j++) c[i]+=ans[j]*mp[i][j]%MOD;
            }
            for(int i=0;i<n;i++) ans[i]=c[i]%MOD;
        }
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
            {
                d[i][j]=0;
                for(int k=0;k<n;k++) d[i][j]+=mp[i][k]*mp[k][j]%MOD;
            }
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++) mp[i][j]=d[i][j]%MOD;
        m>>=1;
    }
}
int main()
{
    int i,j;
    scanf("%d%I64d",&n,&m);
    for(i=0;i<n;i++) scanf("%I64d",&a[i]);
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
        {
            int x=a[i]^a[j],y=0;
            while(x>0)
            {
                y+=x%2;
                x/=2;
            }
            if(y%3==0) mp[i][j]=1;
            else mp[i][j]=0;
        }
    for(i=0;i<n;i++) ans[i]=1;
    ksm(m-1);
    for(i=1;i<n;i++) ans[0]+=ans[i];
    printf("%I64d\n",ans[0]%MOD);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
bool ch[105][105];
int next1[105];
int next2[105];
bool ok[105][105][100];
int ff[105][105][100],mod=1e9+7,end1,end2;
map<long long int,int> ma;
int cnt=0,n;
int f(int i,int j,long long int n)
{
    if(n==end1) return i==j;
    if(n==end2) return ch[i][j];
    if(ok[i][j][n]++) return ff[i][j][n];
    int &ans=ff[i][j][n];
    for(int x=1;x<=::n;x++)
    {
        ans=(ans+1LL*f(i,x,next1[n])*f(x,j,next2[n]))%mod;
    }
    return ans;
}
long long int a[100010];
void track(long long int n)
{
    if(ma[n]) return;
    ma[n]=++cnt;
    if(n<=2) return;
    track((n+1)/2);
    track(n-(n+1)/2+1);
    next1[ma[n]]=ma[(n+1)/2];
    next2[ma[n]]=ma[n-(n+1)/2+1];
    //printf("%lld %d %d %d\n",n,ma[n],next1[ma[n]],next2[ma[n]]);
}
int main()
{
    long long k,ans=0;
    //freopen("test.inp","r",stdin);
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++) ch[i][j]= __builtin_popcountll(a[i]^a[j])%3?0:1;
    track(k);
    end1=ma[1]; end2=ma[2];
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
    {
        ans+=f(i,j,ma[k]); ans%=mod;
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
bool ch[105][105];
bool ok[105][105][100];
int ff[105][105][100],mod=1e9+7;
map<int,int> ma;
int cnt=0;
int f(int i,int j,int n)
{
    if(n==1) return i==j;
    if(n==2) return ch[i][j];
    int &tmp=ma[n];
    if(!tmp) tmp=++cnt;
    if(ok[i][j][tmp]++) return ff[i][j][tmp];
    int &ans=ff[i][j][tmp];
    for(int x=1;x<=n;x++)
    {
        ans=(ans+1LL*f(i,x,(n+1)/2)*f(x,j,n-(n+1)/2+1))%mod;
    }
    return ans;
}
int a[100010];
int main()
{
    int n,k,ans=0;
    //freopen("test.inp","r",stdin);
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++) ch[i][j]= __builtin_popcount(a[i]^a[j])%3?0:1;
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
    {
        ans+=f(i,j,k); ans%=mod;
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
bool ch[105][105];
int next1[205];
int next2[205];
bool ok[105][105][200];
int ff[105][105][200],mod=1e9+7,end1,end2;
map<long long int,int> ma;
int cnt=0,n;
int f(int i,int j,int n)
{
    if(n==end2) return ch[i][j];
    if(ok[i][j][n]++) return ff[i][j][n];
    int &ans=ff[i][j][n];
    for(int x=1;x<=::n;x++)
    {
        ans=(ans+1LL*f(i,x,next1[n])*f(x,j,next2[n]))%mod;
    }
    return ans;
}
long long int a[1010];
void track(long long int n)
{
    if(ma[n]) return;
    ma[n]=++cnt;
    if(n<=2) return;
    track((n+1)/2);
    track(n-(n+1)/2+1);
    next2[ma[n]]=ma[n-(n+1)/2+1];
    next1[ma[n]]=ma[(n+1)/2];

}
int main()
{
    long long k,ans=0;
    //freopen("test.inp","r",stdin);
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++) ch[i][j]= __builtin_popcountll(a[i]^a[j])%3?0:1;
    track(k);
    end1=ma[1]; end2=ma[2];
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
    {
        if(k==1) ans+=i==j;
        else
        ans+=f(i,j,ma[k]); ans%=mod;
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
bool ch[105][105];
int next1[105];
int next2[105];
bool ok[105][105][100];
int ff[105][105][100],mod=1e9+7,end1,end2;
map<long long int,int> ma;
int cnt=0,n;
int f(int i,int j,long long int n)
{
    if(n==end1) return i==j;
    if(n==end2) return ch[i][j];
    if(ok[i][j][n]++) return ff[i][j][n];
    int &ans=ff[i][j][n];
    for(int x=1;x<=::n;x++)
    {
        ans=(ans+1LL*f(i,x,next1[n])*f(x,j,next2[n]))%mod;
    }
    return ans;
}
long long int a[100010];
void track(long long int n)
{
    if(ma[n]) return;
    ma[n]=++cnt;
    if(n<=2) return;
    track((n+1)/2);
    track(n-(n+1)/2+1);
    next1[ma[n]]=ma[(n+1)/2];
    next2[ma[n]]=ma[n-(n+1)/2+1];
    //printf("%lld %d %d %d\n",n,ma[n],next1[ma[n]],next2[ma[n]]);
}
int main()
{
    long long k,ans=0;
    //freopen("test.inp","r",stdin);
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++) ch[i][j]= __builtin_popcount(a[i]^a[j])%3?0:1;
    track(k);
    end1=ma[1]; end2=ma[2];
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
    {
        ans+=f(i,j,ma[k]); ans%=mod;
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
bool ch[105][105];
bool ok[105][105][100];
int ff[105][105][100],mod=1e9+7;
map<int,int> ma;
int cnt=0,n;
int f(int i,int j,int n)
{
    if(n==1) return i==j;
    if(n==2) return ch[i][j];
    int &tmp=ma[n];
    if(!tmp) tmp=++cnt;
    if(ok[i][j][tmp]++) return ff[i][j][tmp];
    int &ans=ff[i][j][tmp];
    for(int x=1;x<=::n;x++)
    {
        ans=(ans+1LL*f(i,x,(n+1)/2)*f(x,j,n-(n+1)/2+1))%mod;
    }
    return ans;
}
int a[100010];
int main()
{
    int k,ans=0;
    //freopen("test.inp","r",stdin);
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++) ch[i][j]= __builtin_popcount(a[i]^a[j])%3?0:1;
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
    {
        ans+=f(i,j,k); ans%=mod;
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
bool ch[105][105];
int next1[205];
int next2[205];
bool ok[105][105][200];
int ff[105][105][200],mod=1e9+7,end1,end2;
map<long long int,int> ma;
int cnt=0,n;
int f(int i,int j,int n)
{
    if(n==end2) return ch[i][j];
    if(ok[i][j][n]++) return ff[i][j][n];
    int &ans=ff[i][j][n];
    for(int x=1;x<=::n;x++)
    {
        ans=(ans+1LL*f(i,x,next1[n])*f(x,j,next2[n]))%mod;
    }
    return ans;
}
long long int a[1010];
void track(long long int n)
{
    if(ma[n]) return;
    ma[n]=++cnt;
    if(n<=2) return;
    track((n+1)/2);
    track(n-(n+1)/2+1);
    next2[ma[n]]=ma[n-(n+1)/2+1];
    next1[ma[n]]=ma[(n+1)/2];

}
int main()
{
    long long k,ans=0;
    freopen("test.inp","r",stdin);
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++) ch[i][j]= __builtin_popcountll(a[i]^a[j])%3?0:1;
    track(k);
    end1=ma[1]; end2=ma[2];
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
    {
        ans+=f(i,j,ma[k]); ans%=mod;
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
bool ch[105][105];
bool ok[105][105][100];
int ff[105][105][100],mod=1e9+7;
map<int,int> ma;
int cnt=0;
int f(int i,int j,int n)
{
    if(n==1) return i==j;
    if(n==2) return ch[i][j];
    int &tmp=ma[n];
    if(!tmp) tmp=++cnt;
    if(ok[i][j][tmp]++) return ff[i][j][tmp];
    int &ans=ff[i][j][tmp];
    for(int x=1;x<=n;x++)
    {
        ans=(ans+1LL*f(i,x,(n+1)/2)*f(x,j,n-(n+1)/2+1))%mod;
    }
    return ans;
}
int a[100010];
int main()
{
    int n,k,ans=0;
    //freopen("test.inp","r",stdin);
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++) ch[i][j]= __builtin_popcount(a[i]^a[j])%3?0:1;
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
    {
        ans+=f(i,j,k);
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
bool ch[105][105];
int next1[205];
int next2[205];
bool ok[105][105][200];
int ff[105][105][200],mod=1e9+7,end1,end2;
map<long long int,int> ma;
int cnt=0,n;
int f(int i,int j,int n)
{
    if(n==end2) return ch[i][j];
    if(ok[i][j][n]++) return ff[i][j][n];
    int &ans=ff[i][j][n];
    for(int x=1;x<=::n;x++)
    {
        ans=(ans+1LL*f(i,x,next1[n])*f(x,j,next2[n]))%mod;
    }
    return ans;
}
long long int a[1010];
void track(long long int n)
{
    if(ma[n]) return;
    ma[n]=++cnt;
    if(n<=2) return;
    track((n+1)/2);
    track(n-(n+1)/2+1);
    next2[ma[n]]=ma[n-(n+1)/2+1];
    next1[ma[n]]=ma[(n+1)/2];

}
int main()
{
    long long k,ans=0;
    //freopen("test.inp","r",stdin);
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++) ch[i][j]= __builtin_popcountll(a[i]^a[j])%3?0:1;
    track(k);
    end1=ma[1]; end2=ma[2];
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
    {
        ans+=f(i,j,ma[k]); ans%=mod;
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
bool ch[105][105];
int next1[105];
int next2[105];
bool ok[105][105][300];
int ff[105][105][300],mod=1e9+7,end1,end2;
map<long long int,int> ma;
int cnt=0,n;
int f(int i,int j,long long int n)
{
    if(n==end1) return i==j;
    if(n==end2) return ch[i][j];
    if(ok[i][j][n]++) return ff[i][j][n];
    int &ans=ff[i][j][n];
    for(int x=1;x<=::n;x++)
    {
        ans=(ans+1LL*f(i,x,next1[n])*f(x,j,next2[n]))%mod;
    }
    return ans;
}
long long int a[100010];
void track(long long int n)
{
    if(ma[n]) return;
    ma[n]=++cnt;
    if(n<=2) return;
    track((n+1)/2);
    track(n-(n+1)/2+1);
    next1[ma[n]]=ma[(n+1)/2];
    next2[ma[n]]=ma[n-(n+1)/2+1];
    //printf("%lld %d %d %d\n",n,ma[n],next1[ma[n]],next2[ma[n]]);
}
int main()
{
    long long k,ans=0;
    //freopen("test.inp","r",stdin);
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++) ch[i][j]= __builtin_popcountll(a[i]^a[j])%3?0:1;
    track(k);
    end1=ma[1]; end2=ma[2];
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
    {
        ans+=f(i,j,ma[k]); ans%=mod;
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
bool ch[105][105];
int next1[205];
int next2[205];
bool ok[105][105][300];
int ff[105][105][300],mod=1e9+7,end1,end2;
map<long long int,int> ma;
int cnt=0,n;
int f(int i,int j,int n)
{
    if(n==end1) return i==j;
    if(n==end2) return ch[i][j];
    if(ok[i][j][n]++) return ff[i][j][n];
    int &ans=ff[i][j][n];
    for(int x=1;x<=::n;x++)
    {
        ans=(ans+1LL*f(i,x,next1[n])*f(x,j,next2[n]))%mod;
    }
    return ans;
}
long long int a[100010];
void track(long long int n)
{
    if(ma[n]) return;
    ma[n]=++cnt;
    if(n<=2) return;
    track((n+1)/2);
    track(n-(n+1)/2+1);
    next2[ma[n]]=ma[n-(n+1)/2+1];
    next1[ma[n]]=ma[(n+1)/2];

}
int main()
{
    long long k,ans=0;
    //freopen("test.inp","r",stdin);
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++) ch[i][j]= __builtin_popcountll(a[i]^a[j])%3?0:1;
    track(k);
    end1=ma[1]; end2=ma[2];
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
    {
        ans+=f(i,j,ma[k]); ans%=mod;
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
bool ch[105][105];
bool ok[105][105][100];
int ff[105][105][100],mod=1e9+7;
map<long long int,int> ma;
int cnt=0,n;
int f(int i,int j,long long int n)
{
    if(n==1) return i==j;
    if(n==2) return ch[i][j];
    int &tmp=ma[n];
    if(!tmp) tmp=++cnt;
    if(ok[i][j][tmp]++) return ff[i][j][tmp];
    int &ans=ff[i][j][tmp];
    for(int x=1;x<=::n;x++)
    {
        ans=(ans+1LL*f(i,x,(n+1)/2)*f(x,j,n-(n+1)/2+1))%mod;
    }
    return ans;
}
int a[100010];
int main()
{
    long long k,ans=0;
    //freopen("test.inp","r",stdin);
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++) ch[i][j]= __builtin_popcount(a[i]^a[j])%3?0:1;
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
    {
        ans+=f(i,j,k); ans%=mod;
    }
    cout<<ans;
}


#include <bits/stdc++.h>
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define ll long long
#define popcount(x) __builtin_popcount(x)
#define MOD 1000000007
using namespace std;
#define N 110

int n,k;
ll a[N][N], b[N][N];
ll g[N][N];
ll tmp[N][N];
ll res[N][N];

void mul() {
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			tmp[i][j] = 0;
			for(int k=0;k<n;k++) {
				tmp[i][j] += a[i][k] * b[k][j];
				tmp[i][j] %= MOD;
			}
		}
	}
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			a[i][j] = tmp[i][j];
		}
	}
}

void fastexp(int e) {

	for(int i=0;i<n;i++) res[i][i] = 1;

	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++) {
			a[i][j] = b[i][j] = g[i][j];
		}
	}
	if(e == 0) return;
	while(e > 1) {
		mul();

		if(e % 2 == 1) {
			mul();
			e--;
		}
		e/=2;
		for(int i=0;i<n;i++) {
			for(int j=0;j<n;j++) {
				b[i][j] = a[i][j];
			}
		}

		//for(int i=0; i<n;i++) {
		//for(int k=0;k<n;k++) {
	//		printf("%lld ", a[i][k]);
		//}
		//printf("\n");
	//}printf("\n");
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++) {
			res[i][j] = a[i][j];
		}
	}

}

int main () {

	ll v[N];

	scanf("%d %d", &n, &k);
	for(int i=0;i<n;i++) {
		scanf("%lld", &v[i]);
	}

	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			if(popcount(v[i] ^ v[j]) % 3 == 0) {
				g[i][j] = 1;
			}
			//printf("%lld ", g[i][j]);
		}
		//printf("\n");
	}
	//p/rintf("\n");

	fastexp(k-1);

	ll resp = 0;

	for(int i=0; i<n;i++) {
		for(int k=0;k<n;k++) {
			//printf("%lld ", res[i][k]);
			resp += res[i][k];
			resp %= MOD;
		}
		//printf("\n");
	}//printf("\n");

	cout << resp << "\n";

}


#include <bits/stdc++.h>
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define ll long long
#define For(i,x,y) for(int i=x; i<y; i++)
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define MOD 1000000007
using namespace std;
#define N 110

int n;
vector<vector<ll> > g;
vector<vector<ll> > tmp;

void mul(vector<vector<ll> > &a, vector<vector<ll> > &b) {
	For(i,0,n) {
		For(j,0,n) {
			tmp[i][j] = 0;
			For(x,0,n) {
				tmp[i][j] += a[i][x]*b[x][j];
				tmp[i][j] %= MOD;
			}
		}
	}
	For(i,0,n) {
		For(j,0,n) a[i][j] = tmp[i][j];
	}
}

vector<vector<ll> > fastexp(vector<vector<ll> > a, ll e) {
	vector<vector<ll> > res(n, vector<ll>(n,0));
	For(i,0,n) res[i][i] = 1;
	while(e) {
		if(e&1) {
			mul(res,a);
		}
		mul(a,a);
		e >>= 1;
	}
	return res;
}

int main () {

	ll v[N];
	vector<vector<ll> > res;
	ll k;

	scanf("%d %lld", &n, &k);
	for(int i=0;i<n;i++) {
		scanf("%lld", &v[i]);
	}

	tmp.resize(n, vector<ll>(n,0));
	g.resize(n, vector<ll>(n,0));

	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			if(popcountll(v[i] ^ v[j]) % 3 == 0) {
				g[i][j] = 1;
			}
			//printf("%lld ", g[i][j]);
		}
		//printf("\n");
	}
	//p/rintf("\n");

	res = fastexp(g, k-1);

	ll resp = 0;

	for(int i=0; i<n;i++) {
		for(int x=0;x<n;x++) {
			//printf("%lld ", res[i][k]);
			resp += res[i][x];
			resp %= MOD;
		}
		//printf("\n");
	}//printf("\n");

	cout << resp << "\n";
}


#include <bits/stdc++.h>
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define ll long long
#define For(i,x,y) for(int i=x; i<y; i++)
#define popcount(x) __builtin_popcount(x)
#define MOD 1000000007
using namespace std;
#define N 110

int n;
vector<vector<ll> > g;
vector<vector<ll> > tmp;

void mul(vector<vector<ll> > &a, vector<vector<ll> > &b) {
	For(i,0,n) {
		For(j,0,n) {
			tmp[i][j] = 0;
			For(k,0,n) {
				tmp[i][j] += a[i][k]*b[k][j];
				tmp[i][j] %= MOD;
			}
		}
	}
	For(i,0,n) {
		For(j,0,n) a[i][j] = tmp[i][j];
	}
}

vector<vector<ll> > fastexp(vector<vector<ll> > a, ll e) {
	vector<vector<ll> > res(n, vector<ll>(n,0));
	For(i,0,n) res[i][i] = 1;
	while(e) {
		if(e&1) {
			mul(res,a);
		}
		mul(a,a);
		e >>= 1;
	}
	return res;
}

int main () {

	ll v[N];
	vector<vector<ll> > res;
	ll k;

	scanf("%d %lld", &n, &k);
	for(int i=0;i<n;i++) {
		scanf("%lld", &v[i]);
	}

	tmp.resize(n, vector<ll>(n,0));
	g.resize(n, vector<ll>(n,0));

	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			if(popcount(v[i] ^ v[j]) % 3 == 0) {
				g[i][j] = 1;
			}
			//printf("%lld ", g[i][j]);
		}
		//printf("\n");
	}
	//p/rintf("\n");

	res = fastexp(g, k-1);

	ll resp = 0;

	for(int i=0; i<n;i++) {
		for(int x=0;x<n;x++) {
			//printf("%lld ", res[i][k]);
			resp += res[i][x];
			resp %= MOD;
		}
		//printf("\n");
	}//printf("\n");

	cout << resp << "\n";

}


#include <bits/stdc++.h>
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define ll long long
#define MOD 1000000007
using namespace std;
#define N 110

int n,k;
ll a[N][N], b[N][N];
ll g[N][N];
ll tmp[N][N];
ll res[N][N];

void mul() {
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			tmp[i][j] = 0;
			for(int k=0;k<n;k++) {
				tmp[i][j] += a[i][k] * b[k][j];
				tmp[i][j] %= MOD;
			}
		}
	}
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			a[i][j] = tmp[i][j];
		}
	}
}

void fastexp(int e) {

	for(int i=0;i<n;i++) res[i][i] = 1;

	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++) {
			a[i][j] = b[i][j] = g[i][j];
		}
	}
	if(e == 0) return;
	while(e > 1) {
		mul();

		if(e % 2 == 1) {
			mul();
			e--;
		}
		e/=2;
		for(int i=0;i<n;i++) {
			for(int j=0;j<n;j++) {
				b[i][j] = a[i][j];
			}
		}

		//for(int i=0; i<n;i++) {
		//for(int k=0;k<n;k++) {
	//		printf("%lld ", a[i][k]);
		//}
		//printf("\n");
	//}printf("\n");
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++) {
			res[i][j] = a[i][j];
		}
	}

}

int main () {

	ll v[N];

	scanf("%d %d", &n, &k);
	for(int i=0;i<n;i++) {
		scanf("%lld", &v[i]);
	}

	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			if((v[i] ^ v[j]) % 3 == 0) {
				g[i][j] = 1;
			}
			//printf("%lld ", g[i][j]);
		}
		//printf("\n");
	}
	//printf("\n");

	fastexp(k-1);

	ll resp = 0;

	for(int i=0; i<n;i++) {
		for(int k=0;k<n;k++) {
			//printf("%lld ", res[i][k]);
			resp += res[i][k];
			resp %= MOD;
		}
		//printf("\n");
	}//printf("\n");

	cout << resp << "\n";

}


#include <bits/stdc++.h>
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define ll long long
#define For(i,x,y) for(int i=x; i<y; i++)
#define popcount(x) __builtin_popcount(x)
#define MOD 1000000007
using namespace std;
#define N 110

int n;
ll k;

vector<vector<ll> > g;
vector<vector<ll> > tmp;

void mul(vector<vector<ll> > &a, vector<vector<ll> > &b) {
	For(i,0,n) {
		For(j,0,n) {
			tmp[i][j] = 0;
			For(k,0,n) {
				tmp[i][j] += a[i][k]*b[k][j];
				tmp[i][j] %= MOD;
			}
		}
	}
	For(i,0,n) {
		For(j,0,n) a[i][j] = tmp[i][j];
	}
}

vector<vector<ll> > fastexp(vector<vector<ll> > a, ll e) {
	vector<vector<ll> > res(n, vector<ll>(n,0));
	For(i,0,n) res[i][i] = 1;
	while(e) {
		if(e&1) {
			mul(res,a);
		}
		mul(a,a);
		e >>= 1;
	}
	return res;
}

int main () {

	ll v[N];
	vector<vector<ll> > res;

	scanf("%d %lld", &n, &k);
	for(int i=0;i<n;i++) {
		scanf("%lld", &v[i]);
	}

	tmp.resize(n, vector<ll>(n,0));
	g.resize(n, vector<ll>(n,0));

	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			if(popcount(v[i] ^ v[j]) % 3 == 0) {
				g[i][j] = 1;
			}
			//printf("%lld ", g[i][j]);
		}
		//printf("\n");
	}
	//p/rintf("\n");

	res = fastexp(g, k-1);

	ll resp = 0;

	for(int i=0; i<n;i++) {
		for(int k=0;k<n;k++) {
			//printf("%lld ", res[i][k]);
			resp += res[i][k];
			resp %= MOD;
		}
		//printf("\n");
	}//printf("\n");

	cout << resp << "\n";

}


#include <bits/stdc++.h>
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define ll long long
#define For(i,x,y) for(int i=x; i<y; i++)
#define popcount(x) __builtin_popcount(x)
#define MOD 1000000007
using namespace std;
#define N 110

int n;
vector<vector<ll> > g;
vector<vector<ll> > tmp;

void mul(vector<vector<ll> > &a, vector<vector<ll> > &b) {
	For(i,0,n) {
		For(j,0,n) {
			tmp[i][j] = 0;
			For(x,0,n) {
				tmp[i][j] += a[i][x]*b[x][j];
				tmp[i][j] %= MOD;
			}
		}
	}
	For(i,0,n) {
		For(j,0,n) a[i][j] = tmp[i][j];
	}
}

vector<vector<ll> > fastexp(vector<vector<ll> > a, ll e) {
	vector<vector<ll> > res(n, vector<ll>(n,0));
	For(i,0,n) res[i][i] = 1;
	while(e) {
		if(e&1) {
			mul(res,a);
		}
		mul(a,a);
		e >>= 1;
	}
	return res;
}

int main () {

	ll v[N];
	vector<vector<ll> > res;
	ll k;

	scanf("%d %lld", &n, &k);
	for(int i=0;i<n;i++) {
		scanf("%lld", &v[i]);
	}

	tmp.resize(n, vector<ll>(n,0));
	g.resize(n, vector<ll>(n,0));

	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			if(popcount(v[i] ^ v[j]) % 3 == 0) {
				g[i][j] = 1;
			}
			//printf("%lld ", g[i][j]);
		}
		//printf("\n");
	}
	//p/rintf("\n");

	res = fastexp(g, k-1);

	ll resp = 0;

	for(int i=0; i<n;i++) {
		for(int x=0;x<n;x++) {
			//printf("%lld ", res[i][k]);
			resp += res[i][x];
			resp %= MOD;
		}
		//printf("\n");
	}//printf("\n");

	cout << resp << "\n";
}


#include <bits/stdc++.h>
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define ll long long
#define For(i,x,y) for(int i=x; i<y; i++)
#define popcount(x) __builtin_popcount(x)
#define MOD 1000000007
using namespace std;
#define N 110

int n,k;

vector<vector<ll> > g;
vector<vector<ll> > tmp;

void mul(vector<vector<ll> > &a, vector<vector<ll> > &b) {
	For(i,0,n) {
		For(j,0,n) {
			tmp[i][j] = 0;
			For(k,0,n) {
				tmp[i][j] += a[i][k]*b[k][j];
				tmp[i][j] %= MOD;
			}
		}
	}
	For(i,0,n) {
		For(j,0,n) a[i][j] = tmp[i][j];
	}
}

vector<vector<ll> > fastexp(vector<vector<ll> > a, int e) {
	vector<vector<ll> > res(n, vector<ll>(n,0));
	For(i,0,n) res[i][i] = 1;
	while(e) {
		if(e&1) {
			mul(res,a);
		}
		mul(a,a);
		e >>= 1;
	}
	return res;
}

int main () {

	ll v[N];
	vector<vector<ll> > res;

	scanf("%d %d", &n, &k);
	for(int i=0;i<n;i++) {
		scanf("%lld", &v[i]);
	}

	tmp.resize(n, vector<ll>(n,0));
	g.resize(n, vector<ll>(n,0));

	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			if(popcount(v[i] ^ v[j]) % 3 == 0) {
				g[i][j] = 1;
			}
			//printf("%lld ", g[i][j]);
		}
		//printf("\n");
	}
	//p/rintf("\n");

	res = fastexp(g, k-1);

	ll resp = 0;

	for(int i=0; i<n;i++) {
		for(int k=0;k<n;k++) {
			//printf("%lld ", res[i][k]);
			resp += res[i][k];
			resp %= MOD;
		}
		//printf("\n");
	}//printf("\n");

	cout << resp << "\n";

}


#include <cstdio>
#include <iostream>
#include <cstring>
#define MOD 1000000007
#define MAXN 105
using namespace std;
long long n,k,ans;
//快读快写
inline long long read(){
	char ch;
	long long f=1,x=0;
	ch=getchar();
	while (ch>'9'||ch<'0'){
		if (ch=='-'){
			f=-1;
		}
		ch=getchar();
	}
	while (ch<='9'&&ch>='0'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return f*x;
}
inline void print(long long x){
	if (x<0) x=-x,putchar('-');
	if (x>9) print(x/10);
	putchar(x%10+'0');
}

struct binary{
	bool num[65];
	long long len;
	void clear(){
		memset(num,0,sizeof(num));
	}
	void convert(long long a){
		long long i=0;
		while (a>0){
			num[i++]=a&1;
			a>>=1;
		}
		len=i;
	}
	long long SumTrue(){
		long long sum=0;
		for (long long j=0;j<len;j++){
			sum+=num[j];
		}
		return sum;
	}
}a[MAXN];
binary operator ^ (const binary &a,const binary &b){
	binary c;
	long long maxlen=max(a.len,b.len);
	for (long long i=0;i<maxlen;i++){
		c.num[i]=a.num[i] xor b.num[i];
	}
	c.len=maxlen;
	return c;
}

struct matrix{
	long long v[MAXN][MAXN];
	void clear(){
		memset(v,0,sizeof(v));
	}
	void YPYlovesDYF(){
		for (long long i=0;i<n;i++){
			for (long long j=0;j<n;j++){
			    binary c=a[i]^a[j];
			    v[i][j]=(c.SumTrue()%3==0);
			}
		}
	}
};
matrix operator *(const matrix &a,const matrix &b){
	matrix ans;
	ans.clear();
	for (long long i=0;i<n;i++){
		for (long long j=0;j<n;j++){
			for (long long k=0;k<n;k++){
				ans.v[i][j]=(ans.v[i][j]+a.v[i][k]*b.v[k][j])%MOD;
			}
		}
	}
	return ans;
}
//矩阵快速幂
matrix ksm(matrix a,long long pows){
	matrix ans;
	ans.clear();
	for (long long i=0;i<n;i++){
	    ans.v[i][i]=1;
	}
	while (pows>0){
		if (pows&1){
			ans=ans*a;
		}
		a=a*a;
		pows>>=1;
	}
	return ans;
}

int main(){
	n=read();
	k=read();
	long long temp;
	for (long long i=0;i<n;i++){
		temp=read();
		a[i].clear();
		a[i].convert(temp);
	}
	matrix ans;
	ans.YPYlovesDYF();
	ans=ksm(ans,k-1);
	long long ret=0;
	for (long long i=0;i<n;i++){
	    for (long long j=0;j<n;j++){
	        ret=(ret+ans.v[i][j])%MOD;
	    }
	}
	print(ret);
	return 0;
}


#include <cstdio>
#include <cstring>
#define MOD 1000000007
int n;
long long m,ans,lst[110];
struct rect
{
    int p,q;
    long long v[110][110];
    rect() { memset(v,0,sizeof(v));}
}A;
rect operator * (const rect &a,const rect &b)
{
    int i,j,k;
    rect ret;
    for(i=1;i<=a.p;i++) for(j=1;j<=b.q;j++) for(k=1;k<=a.q;k++)
        ret.v[i][j] = (ret.v[i][j] + a.v[i][k] * b.v[k][j])%MOD;
    return ret;
}
rect power(const rect &a,long long b)
{
    int i;
    rect base = a,y;
    y.p = y.q = a.p;
    for(i=1;i<=y.p;i++) y.v[i][i] = 1;
    for(;b;b>>=1)
    {
        if(b&1) y = y*base;
        base = base*base;
    }
    return y;
}
void build()
{
    int i,j,k,cnt;
    long long x;
    A.p = A.q = n;
    for(i=1;i<=n;i++) for(j=1;j<=n;j++)
    {
        x = lst[i]^lst[j]; cnt = 0;
        for(;x;x>>=1) cnt += x&1;
        A.v[i][j] = (cnt%3==0);
    }
}
int main()
{
    int i,j;
    scanf("%d%I64d",&n,&m);
    if(m == 1) { printf("%d",n); return 0;}
    for(i=1;i<=n;i++) scanf("%I64d",&lst[i]);
    build();
    A = power(A,m-1);
    for(i=1;i<=n;i++) for(j=1;j<=n;j++) ans = (ans + A.v[i][j])%MOD;
    printf("%I64d",ans);
    return 0;
}


#include <cstdio>
#include <cstring>
#define MOD 1000000007
int n;
long long m,ans,lst[110];
struct rect
{
    int p,q;
    long long v[110][110];
    rect() { memset(v,0,sizeof(v));}
}A;
rect operator * (const rect &a,const rect &b)
{
    int i,j,k;
    rect ret;
    ret.p = a.p; ret.q = b.q;
    for(i=1;i<=a.p;i++) for(j=1;j<=b.q;j++) for(k=1;k<=a.q;k++)
        ret.v[i][j] = (ret.v[i][j] + a.v[i][k] * b.v[k][j])%MOD;
    return ret;
}
rect power(const rect &a,long long b)
{
    int i;
    rect base = a,y;
    y.p = y.q = a.p;
    for(i=1;i<=y.p;i++) y.v[i][i] = 1;
    for(;b;b>>=1)
    {
        if(b&1) y = y*base;
        base = base*base;
    }
    return y;
}
void build()
{
    int i,j,k,cnt;
    long long x;
    A.p = A.q = n;
    for(i=1;i<=n;i++) for(j=1;j<=n;j++)
    {
        x = lst[i]^lst[j]; cnt = 0;
        for(;x;x>>=1) cnt += x&1;
        A.v[i][j] = (cnt%3==0);
    }
}
int main()
{
    int i,j;
    scanf("%d%I64d",&n,&m);
    if(m == 1) { printf("%d",n); return 0;}
    for(i=1;i<=n;i++) scanf("%I64d",&lst[i]);
    build();
    A = power(A,m-1);
    for(i=1;i<=n;i++) for(j=1;j<=n;j++) ans = (ans + A.v[i][j])%MOD;
    printf("%I64d",ans);
    return 0;
}


/*
  ------------------------- Hachiikung ---------------------------------
  ---------------------- Worrachate Bosri ------------------------------
  ------ Faculty of Computer Engineering Chulalongkorn University ------
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i,FN) for(int i=0;i<FN;i++)
#define FOR(i,ST,FN) for(int i=ST;i<=FN;i++)
#define FORD(i,FN,ST) for(int i=FN;i>=ST;i--)
#define FORX(i,c) for(typeof(c.begin())i=c.begin();i!=c.end();i++)
#define pause system("pause")
#define S scanf
#define P printf
#define X first
#define Y second
#define pb push_back
#define PII pair<int,int>
#define mp make_pair
#define sz size()
#define eps 1e-8

const int MOD(1000000007);
const int INF((1<<30)-1);
const int MAXN(105);

long long a[MAXN], d[MAXN][MAXN], tmp[MAXN][MAXN], m[MAXN][MAXN];

int main(){

    int n;
    long long k;
    cin >> n >> k;
    REP(i,n)
        cin >> a[i];

    if(k == 1)
    {
        P("%d",n);
        return 0;
    }

    REP(i,n)
        REP(j,n)
        {
            int cnt = 0;
            long long x = a[i]^a[j];

            while(x > 0)
            {
                cnt++;
                x -= x&(-x);
            }

            d[i][j] = (cnt%3 == 0);
        }

    REP(i,n)
        REP(j,n)
            m[i][j] = d[i][j];

    k -= 2;

    while(k > 0)
    {
        if(k&1)
        {
            REP(i,n)
                REP(j,n)
                    tmp[i][j] = 0;

            REP(i,n)
                REP(j,n)
                    REP(k,n)
                    {
                        tmp[i][j] += m[i][k]*d[k][j];
                        tmp[i][j] %= MOD;
                    }

            REP(i,n)
                REP(j,n)
                    m[i][j] = tmp[i][j];
        }

        REP(i,n)
            REP(j,n)
                tmp[i][j] = 0;

        REP(i,n)
            REP(j,n)
                REP(k,n)
                {
                    tmp[i][j] += d[i][k]*d[k][j];
                    tmp[i][j] %= MOD;
                }

        REP(i,n)
            REP(j,n)
                d[i][j] = tmp[i][j];

        k >>= 1;
    }

    long long ans = 0;

    REP(i,n)
        REP(j,n)
        {
            ans += m[i][j];
            ans %= MOD;
        }

    P("%I64d",ans);

}


/*
  ------------------------- Hachiikung ---------------------------------
  ---------------------- Worrachate Bosri ------------------------------
  ------ Faculty of Computer Engineering Chulalongkorn University ------
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i,FN) for(int i=0;i<FN;i++)
#define FOR(i,ST,FN) for(int i=ST;i<=FN;i++)
#define FORD(i,FN,ST) for(int i=FN;i>=ST;i--)
#define FORX(i,c) for(typeof(c.begin())i=c.begin();i!=c.end();i++)
#define pause system("pause")
#define S scanf
#define P printf
#define X first
#define Y second
#define pb push_back
#define PII pair<int,int>
#define mp make_pair
#define sz size()
#define eps 1e-8

const int MOD(1000000007);
const int INF((1<<30)-1);
const int MAXN(105);

int a[MAXN];

long long d[MAXN][MAXN], tmp[MAXN][MAXN], m[MAXN][MAXN];

int main(){

    int n;
    long long k;
    cin >> n >> k;
    REP(i,n)
        S("%d",&a[i]);

    if(k == 1)
    {
        P("%d",n);
        return 0;
    }

    REP(i,n)
        REP(j,n)
        {
            int x = a[i]^a[j], cnt = 0;

            while(x > 0)
            {
                cnt++;
                x -= x&(-x);
            }

            d[i][j] = (cnt%3 == 0);
        }

    REP(i,n)
        REP(j,n)
            m[i][j] = d[i][j];

    k -= 2;

    while(k > 0)
    {
        if(k&1)
        {
            REP(i,n)
                REP(j,n)
                    tmp[i][j] = 0;

            REP(i,n)
                REP(j,n)
                    REP(k,n)
                    {
                        tmp[i][j] += m[i][k]*d[k][j];
                        tmp[i][j] %= MOD;
                    }

            REP(i,n)
                REP(j,n)
                    m[i][j] = tmp[i][j];
        }

        REP(i,n)
            REP(j,n)
                tmp[i][j] = 0;

        REP(i,n)
            REP(j,n)
                REP(k,n)
                {
                    tmp[i][j] += d[i][k]*d[k][j];
                    tmp[i][j] %= MOD;
                }

        REP(i,n)
            REP(j,n)
                d[i][j] = tmp[i][j];

        k >>= 1;
    }

    long long ans = 0;

    REP(i,n)
        REP(j,n)
        {
            ans += m[i][j];
            ans %= MOD;
        }

    P("%I64d",ans);

}


#include <bits/stdc++.h>
#define maxn 105
#define ll long long
#define mo 1000000007
using namespace std;

inline int read(){
	int x=0,f=1;char cc=getchar();
	while(cc<'0' || cc>'9') {if(cc=='-') f=-1;cc=getchar();}
	while(cc>='0' && cc<='9') {x=x*10+cc-'0';cc=getchar();}
	return x*f;
}

inline ll lread(){
	ll x=0,f=1;char cc=getchar();
	while(cc<'0' || cc>'9') {if(cc=='-') f=-1;cc=getchar();}
	while(cc>='0' && cc<='9') {x=x*10+cc-'0';cc=getchar();}
	return x*f;
}

int n,ans;
ll a[maxn],k;
struct matrix{
    int a[maxn][maxn];
    matrix operator *(const matrix &b){
        matrix ret;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                ret.a[i][j]=0;
                for(int k=1;k<=n;k++) ret.a[i][j]=(1ll*a[i][k]*b.a[k][j]+ret.a[i][j])%mo;
            }
        }
        return ret;
    }
} f,d;

inline matrix ksm(matrix a,ll b){
	matrix r;
	for(int i=1;i<=n;i++) r.a[i][i]=1;
	while(b){
		if(b&1) r=r*a;
		a=a*a;
		b>>=1;
	}
	return r;
}

int main(){
	n=read();k=lread();
	for(int i=1;i<=n;i++) a[i]=lread();
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++){
		ll x=a[i]^a[j];int y=0;
		while(x){
			if(x&1) y++;
			x>>=1;
		}
		if(y%3==0) d.a[i][j]=1;
	}
	for(int i=1;i<=n;i++) f.a[1][i]=1;
	d=ksm(d,k-1);f=f*d;
	ans=0;
	for(int i=1;i<=n;i++) ans=(ans+f.a[1][i])%mo;
	printf("%d",ans);
}


#include <bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

int n;
long long k;
long long a[105];
const int mod = 1000000007;
long long graph[105][105];

vvi multiply(vvi A, vvi B) {
    vvi ret = vvi(n, vi(n));
    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) for (int k = 0; k < n; k++) {
        ret[i][j] = (ret[i][j] + A[i][k] * B[k][j]) % mod;
    }
    return ret;
}

vvi fastexp(int k) {
    vvi curr = vvi(n, vi(n));
    vvi power = vvi(n, vi(n));
    for (int i = 0; i < n; i++) curr[i][i] = 1;
    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) power[i][j] = graph[i][j];
    while (k) {
        if (k & 1) curr = multiply(curr, power);
        power = multiply(power, power);
        k >>= 1;
    }
    return curr;
}

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) for (int j = i; j < n; j++) {
        if (__builtin_popcountll(a[i] ^ a[j]) % 3 == 0) graph[i][j] = graph[j][i] = 1;
    }
    vvi g = fastexp(k - 1);
    long long ans = 0;
    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) ans = (ans + g[i][j]) % mod;
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef vector<long long> vi;
typedef vector<vi> vvi;

int n;
long long k;
long long a[105];
const int mod = 1000000007;
long long graph[105][105];

vvi multiply(vvi A, vvi B) {
    vvi ret = vvi(n, vi(n));
    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) for (int k = 0; k < n; k++) {
        ret[i][j] = (ret[i][j] + A[i][k] * B[k][j]) % mod;
    }
    return ret;
}

vvi fastexp(long long k) {
    vvi curr = vvi(n, vi(n));
    vvi power = vvi(n, vi(n));
    for (int i = 0; i < n; i++) curr[i][i] = 1;
    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) power[i][j] = graph[i][j];
    while (k) {
        if (k & 1) curr = multiply(curr, power);
        power = multiply(power, power);
        k >>= 1;
    }
    return curr;
}

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) for (int j = i; j < n; j++) {
        if (__builtin_popcountll(a[i] ^ a[j]) % 3 == 0) graph[i][j] = graph[j][i] = 1;
    }
    vvi g = fastexp(k - 1);
    long long ans = 0;
    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) ans = (ans + g[i][j]) % mod;
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

int n;
long long k;
long long a[105];
const int mod = 1000000007;
long long graph[105][105];

vvi multiply(vvi A, vvi B) {
    vvi ret = vvi(n, vi(n));
    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) for (int k = 0; k < n; k++) {
        ret[i][j] = (ret[i][j] + A[i][k] * B[k][j]) % mod;
    }
    return ret;
}

vvi fastexp(long long k) {
    vvi curr = vvi(n, vi(n));
    vvi power = vvi(n, vi(n));
    for (int i = 0; i < n; i++) curr[i][i] = 1;
    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) power[i][j] = graph[i][j];
    while (k) {
        if (k & 1) curr = multiply(curr, power);
        power = multiply(power, power);
        k >>= 1;
    }
    return curr;
}

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) for (int j = i; j < n; j++) {
        if (__builtin_popcountll(a[i] ^ a[j]) % 3 == 0) graph[i][j] = graph[j][i] = 1;
    }
    vvi g = fastexp(k - 1);
    long long ans = 0;
    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) ans = (ans + g[i][j]) % mod;
    cout << ans << endl;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int MAXN=105 , MOD=1000000007 ;
int n ;
long long A[MAXN] , K ;

struct Matrix{
	int w[MAXN][MAXN] ;
}conv , ans, ini;

Matrix operator*(const Matrix &a,const Matrix &b){
	Matrix c ;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			if(!a.w[i][j]) continue ;
			for(int k=1;k<=n;++k){
				c.w[i][k]+=(int)((long long)a.w[i][j]*b.w[j][k]%MOD) ;
				while(c.w[i][k]>=MOD) c.w[i][k]-=MOD ;
			}
		}
	}
	return c;
}

bool check(long long a){
	int num=0 ;
	while(a){
		if(a&1) ++num ;
		a>>=1 ;
	}
	return !(num%3) ;
}

Matrix matrix_pow(long long b){
	Matrix ret=ini ;
	while(b){
		if(b&1){
			ret=ret*conv ;
		}
		b>>=1 , conv=conv*conv ;
	}
	return ret;
}

int main(){
	scanf("%d%I64d",&n,&K) ;
	for(int i=1;i<=n;++i) scanf("%I64d",&A[i]) ;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			conv.w[i][j]=check(A[i]^A[j]) ;
		}
	}
	if(K==1){
		printf("%d\n",n) ;
		return 0 ;
	}
	for(int i=1;i<=n;++i) ans.w[1][i]=1 , ini.w[i][i]=1 ;
	Matrix tmp=matrix_pow(K-1) ;
	ans=ans*tmp ;
	long long zj=0 ;
	for(int i=1;i<=n;++i){
		zj+=ans.w[1][i] ;
		while(zj>=MOD) zj-=MOD ;
	}
	printf("%I64d\n",zj) ;
	return 0 ;
}