#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] ;

	Matrix(){
		memset(w,0,sizeof(w)) ;
	}
}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(){
	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){
			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 ;
	}
	cout << zj << '\n' ;
	return 0 ;
}


//In the name of good
//#include <bits/stdc++.h>

#include <iostream>

using namespace std ;
#define PB push_back
#define X first
#define Y second
#define ALL(a) a . begin ( ) , a . end ( )
#define print(ab) for(int ii=0;ii<ab.size();ii++)cout<<ab[ii]<< ' ' ;
#define print_pair(ab) for(int i=0;i<ab.size();i++)cout<<ab[i].X<< " " << ab[i].Y<<endl ;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define int  long long
#define ST setprecision ( 12 )
typedef long long ll ;
//typedef long double ld;
//typedef pair < int , int > pii ;
//typedef pair < int , pii > piii ;
//typedef string S ;
//const ld pi = 3.1415926535897932384626433832795 ;
const int maxn = 1e2 + 20;
const int mod = 1e9 + 7  ;
const int inf = 1e9 ;
const int base = 127 ;

struct mat
{
  int val [ maxn ] [ maxn ] ;
} ;

int n , ar [ maxn ] ;
mat  dp [ maxn ] ;
mat a ;

mat mul ( mat &x , mat &y )
{
  mat ret ;
  for ( int i = 0 ; i < n ; i ++ )
    for ( int j = 0 ; j < n ; j ++ )
      {
	ret . val [ i ] [ j ] = 0 ;
	for ( int k = 0 ; k < n ; k ++ )
	  ret . val [ i ] [ j ] = ( ret . val [ i ] [ j ] + ( ( x . val [ i ] [ k ] ) * ( y . val [ k ] [ j ] ) ) ) % mod  ;
      }
  return ret ;
}

int K ;

main ( )
{
  fast ;
  cin >> n >> K ;
  for ( int i = 0 ; i < n ; i ++ )
    cin >> ar [ i ] ;
  for ( int i = 0 ; i < n ; i ++ )
    for ( int j = 0 ; j < n ; j ++ )
      dp [ 0 ] . val [ i ] [ j ] = ( ( __builtin_popcountll ( ar [ i ] ^ ar [ j ] ) % 3 ) == 0 ) ;
  if ( ! ( K > 1 ) )
    {
    cout << n ;
return 0 ;
}
  int ans = 0 ;
  for ( int i = 1 ; i < 60 ; i ++ )
    dp [ i ] = mul ( dp [ i - 1 ] , dp [ i - 1 ] ) ;
  for ( int i = 0 ; i < n ; i ++ )
    a . val [ i ] [ i ] = 1 ;
  for ( int i = 0 ; i < 60 ; i ++ )
    if ( ( ( K - 1 ) >> i ) & 1LL )
      a = mul ( a , dp [ i ] ) ;

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


//In the name of good
#include <bits/stdc++.h>
using namespace std ;
#define PB push_back
#define X first
#define Y second
#define ALL(a) a . begin ( ) , a . end ( )
#define print(ab) for(int ii=0;ii<ab.size();ii++)cout<<ab[ii]<< ' ' ;
#define print_pair(ab) for(int i=0;i<ab.size();i++)cout<<ab[i].X<< " " << ab[i].Y<<endl ;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define int  long long
#define ST setprecision ( 12 )
typedef long long ll ;
typedef long double ld;
typedef pair < int , int > pii ;
typedef pair < int , pii > piii ;
typedef string S ;
const ld pi = 3.1415926535897932384626433832795 ;
const int maxn = 1e2 + 20;
const int mod = 1e9 + 7  ;
const int inf = 1e9 ;
const int base = 127 ;

struct mat
{
  int val [ maxn ] [ maxn ] ;
} ;

int n , ar [ maxn ] ;
mat  dp [ maxn ] ;
mat a ;

int check ( int x )
{
  if ( x < 2 )
    return x % 2 ;
  return check ( x / 2 ) + x % 2 ;
}

mat mul ( mat &x , mat &y )
{
  mat ret ;
  for ( int i = 0 ; i < n ; i ++ )
    for ( int j = 0 ; j < n ; j ++ )
      {
	ret . val [ i ] [ j ] = 0 ;
	for ( int k = 0 ; k < n ; k ++ )
	  ret . val [ i ] [ j ] += ( ( x . val [ i ] [ k ] % mod ) * ( y . val [ k ] [ j ] % mod ) ) % mod , ret . val [ i ] [ j ] %= mod ;
      }
  return ret ;
}

int K ;

main ( )
{
  fast ;
  cin >> n >> K ;
  for ( int i = 0 ; i < n ; i ++ )
    cin >> ar [ i ] ;
  for ( int i = 0 ; i < n ; i ++ )
    for ( int j = 0 ; j < n ; j ++ )
      dp [ 0 ] . val [ i ] [ j ] = ( ( check ( ar [ i ] ^ ar [ j ] ) % 3 ) == 0 ) ;
  if ( ! ( K > 1 ) )
    cout << n , exit ( 0 ) ;
  int ans = 0 ;
  for ( int i = 1 ; i < 64 ; i ++ )
    dp [ i ] = mul ( dp [ i - 1 ] , dp [ i - 1 ] ) ;
  for ( int i = 0 ; i < n ; i ++ )
    a . val [ i ] [ i ] = 1 ;
  for ( int i = 0 ; i < 64 ; i ++ )
    if ( ( ( K - 1 ) >> i ) & 1LL )
      a = mul ( a , dp [ i ] ) ;

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


//In the name of good
#include <bits/stdc++.h>
using namespace std ;
#define PB push_back
#define X first
#define Y second
#define ALL(a) a . begin ( ) , a . end ( )
#define print(ab) for(int ii=0;ii<ab.size();ii++)cout<<ab[ii]<< ' ' ;
#define print_pair(ab) for(int i=0;i<ab.size();i++)cout<<ab[i].X<< " " << ab[i].Y<<endl ;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define int  long long
#define ST setprecision ( 12 )
typedef long long ll ;
typedef long double ld;
typedef pair < int , int > pii ;
typedef pair < int , pii > piii ;
typedef string S ;
const ld pi = 3.1415926535897932384626433832795 ;
const int maxn = 1e2 + 20;
const int mod = 1e9 + 7  ;
const int inf = 1e9 ;
const int base = 127 ;

struct mat
{
  int val [ maxn ] [ maxn ] ;
} ;

int n , ar [ maxn ] ;
mat  dp [ maxn ] ;
mat a ;

int check ( int x )
{
  if ( x < 2 )
    return x % 2 ;
  return check ( x / 2 ) + x % 2 ;
}

mat mul ( mat x , mat y )
{
  mat ret ;
  for ( int i = 0 ; i < n ; i ++ )
    for ( int j = 0 ; j < n ; j ++ )
      {
	ret . val [ i ] [ j ] = 0 ;
	for ( int k = 0 ; k < n ; k ++ )
	  ret . val [ i ] [ j ] += ( ( x . val [ i ] [ k ] % mod ) * ( y . val [ k ] [ j ] % mod ) ) % mod , ret . val [ i ] [ j ] %= mod ;
      }
  return ret ;
}

void prin ( mat x )
{
  for ( int i = 0 ; i < n ; i ++ )
    {
      for ( int j = 0 ; j < n ; j ++ )
	cout << x . val [ i ][ j ] << ' ' ;
      cout << endl ;
    }

}

int K ;

main ( )
{

  cin >> n >> K ;
  for ( int i = 0 ; i < n ; i ++ )
    cin >> ar [ i ] ;
  for ( int i = 0 ; i < n ; i ++ )
    for ( int j = 0 ; j < n ; j ++ )
      dp [ 0 ] . val [ i ] [ j ] = ( ( check ( ar [ i ] ^ ar [ j ] ) % 3 ) == 0 ) ;
  if ( ! ( K > 1 ) )
    cout << n , exit ( 0 ) ;
  int ans = 0 ;
  for ( int i = 1 ; i < 10 ; i ++ )
    dp [ i ] = mul ( dp [ i - 1 ] , dp [ i - 1 ] ) ;
  for ( int i = 0 ; i < n ; i ++ )
    a . val [ i ] [ i ] = 1 ;
  for ( int i = 0 ; i < 10 ; i ++ )
    if ( ( ( K - 1 ) >> i ) & 1LL )
      a = mul ( a , dp [ i ] ) ;

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


//In the name of good
#include <bits/stdc++.h>
using namespace std ;
#define PB push_back
#define X first
#define Y second
#define ALL(a) a . begin ( ) , a . end ( )
#define print(ab) for(int ii=0;ii<ab.size();ii++)cout<<ab[ii]<< ' ' ;
#define print_pair(ab) for(int i=0;i<ab.size();i++)cout<<ab[i].X<< " " << ab[i].Y<<endl ;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define int  long long
#define ST setprecision ( 12 )
typedef long long ll ;
typedef long double ld;
typedef pair < int , int > pii ;
typedef pair < int , pii > piii ;
typedef string S ;
const ld pi = 3.1415926535897932384626433832795 ;
const int maxn = 1e2 + 20;
const int mod = 1e9 + 7  ;
const int inf = 1e9 ;
const int base = 127 ;

struct mat
{
  bool val [ 101 ] [ 101 ] ;
} ;

int n , K , ar [ maxn ] ;
mat a , b ;

int check ( int x )
{
  if ( x < 2 )
    return x % 2 ;
  return check ( x / 2 ) + x % 2 ;
}

mat mul ( mat &x , mat &y )
{
  mat ret ;
  for ( int i = 0 ; i < n ; i ++ )
    for ( int j = 0 ; j < n ; j ++ )
      ret . val [ i ][ j ] = 0 ;
  for ( int i = 0 ; i < n ; i ++ )
    for ( int j = 0 ; j < n ; j ++ )
      for ( int k = 0 ; k < n ; k ++ )
	ret . val [ i ] [ j ] += ( x . val [ i ] [ k ] * y . val [ k ] [ j ] ) % mod , ret . val [ i ] [ j ] %= mod ;
  return ret ;
}

mat pown ( mat x , int y )
{
  if ( y == 0 )
    {
      mat ret ;
      for ( int i = 0 ; i < n ; i ++ )
	ret . val [ i ][ i ] = 1 ;
      return ret ;
    }
  mat ret = pown ( x , y / 2 ) ;
  ret = mul ( ret , ret ) ;
  if ( y & 1 )
    ret = mul ( ret , a ) ;
  return ret ;
}

main ( )
{
  cin >> n >> K ;
  for ( int i = 0 ; i < n ; i ++ )
    cin >> ar [ i ] ;
  for ( int i = 0 ; i < n ; i ++ )
    for ( int j = 0 ; j < n ; j ++ )
      a . val [ i ] [ j ] = ( ( check ( ar [ i ] ^ ar [ j ] ) % 3 ) == 0 ) ;
  a = pown ( a , K - 1 ) ;
  int ans = 0 ;
  for ( int i = 0 ; i < n ; i ++ )
    for ( int j = 0 ; j < n ; j ++ )
      ans += a . val [ i ] [ j ] ;
  cout << ans % mod ;
}


//In the name of good
#include <bits/stdc++.h>
using namespace std ;
#define PB push_back
#define X first
#define Y second
#define ALL(a) a . begin ( ) , a . end ( )
#define print(ab) for(int ii=0;ii<ab.size();ii++)cout<<ab[ii]<< ' ' ;
#define print_pair(ab) for(int i=0;i<ab.size();i++)cout<<ab[i].X<< " " << ab[i].Y<<endl ;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define int  long long
#define ST setprecision ( 12 )
typedef long long ll ;
typedef long double ld;
typedef pair < int , int > pii ;
typedef pair < int , pii > piii ;
typedef string S ;
const ld pi = 3.1415926535897932384626433832795 ;
const int maxn = 1e2 + 20;
const int mod = 1e9 + 7  ;
const int inf = 1e9 ;
const int base = 127 ;

struct mat
{
  int val [ maxn ] [ maxn ] ;
} ;

int n , ar [ maxn ] ;
mat  dp [ maxn ] ;
mat a ;

int check ( int x )
{
  if ( x < 2 )
    return x % 2 ;
  return check ( x / 2 ) + x % 2 ;
}

mat mul ( mat x , mat y )
{
  mat ret ;
  for ( int i = 0 ; i < n ; i ++ )
    for ( int j = 0 ; j < n ; j ++ )
      {
	ret . val [ i ] [ j ] = 0 ;
	for ( int k = 0 ; k < n ; k ++ )
	  ret . val [ i ] [ j ] += ( ( x . val [ i ] [ k ] % mod ) * ( y . val [ k ] [ j ] % mod ) ) % mod , ret . val [ i ] [ j ] %= mod ;
      }
  return ret ;
}

void prin ( mat x )
{
  for ( int i = 0 ; i < n ; i ++ )
    {
      for ( int j = 0 ; j < n ; j ++ )
	cout << x . val [ i ][ j ] << ' ' ;
      cout << endl ;
    }

}

int K ;

main ( )
{

  cin >> n >> K ;
  for ( int i = 0 ; i < n ; i ++ )
    cin >> ar [ i ] ;
  for ( int i = 0 ; i < n ; i ++ )
    for ( int j = 0 ; j < n ; j ++ )
      dp [ 0 ] . val [ i ] [ j ] = ( ( check ( ar [ i ] ^ ar [ j ] ) % 3 ) == 0 ) ;
  if ( ! ( K > 1 ) )
    cout << n , exit ( 0 ) ;
  int ans = 0 ;
  for ( int i = 1 ; i < 100 ; i ++ )
    dp [ i ] = mul ( dp [ i - 1 ] , dp [ i - 1 ] ) ;
  for ( int i = 0 ; i < n ; i ++ )
    a . val [ i ] [ i ] = 1 ;
  for ( int i = 0 ; i < 64 ; i ++ )
    if ( ( ( K - 1 ) >> i ) & 1LL )
      a = mul ( a , dp [ i ] ) ;

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


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iostream>
using namespace std;
#define LL unsigned long long
const LL mod=1e9+7;
const int N=1e2+6;
const int M=10005;
LL a[N];
LL b[N][N];
int n;
struct matrix
{
    LL a[N][N];
};
matrix multi(matrix A,matrix B)
{
    matrix C;
    for(int i=0;i<n;i++)
       for(int j=0;j<n;j++)
       {
           C.a[i][j]=0;
           for(int k=0;k<n;k++)
           {
              C.a[i][j]+=A.a[i][k]*B.a[k][j]%mod;
              C.a[i][j]%=mod;
           }
       }
    return C;
}
matrix quick(matrix A,LL k)
{
    matrix E;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)E.a[i][j]=(i==j);
    while(k)
    {
        if(k&1)E=multi(E,A);
        k>>=1;
        A=multi(A,A);
    }
    return E;
}

int main()
{
//    freopen("in.txt","r",stdin);
    LL k;
    while(cin>>n>>k)
    {
        k--;
        for(int i=0;i<n;i++)cin>>a[i];
        matrix ans;

        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                LL t=(a[i]^a[j]);
                LL cnt=0;
                for(int l=0;l<63;l++)
                {
                   if(t&((LL)1<<l))cnt++;
                }
                if(cnt%3==0)ans.a[i][j]=1;
                else ans.a[i][j]=0;
            }
        }

        matrix temp=quick(ans,k);
        LL sum=0;
        for(int i=0;i<n;i++)
           for(int j=0;j<n;j++)sum=(sum+temp.a[i][j])%mod;
        cout << sum <<endl;
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iostream>
using namespace std;
#define LL long long
const LL mod=1e9+7;
const int N=1e2+6;
const int M=10005;
LL a[N];
LL b[N][N];
int n;
struct matrix
{
    LL a[N][N];
};
matrix multi(matrix A,matrix B)
{
    matrix C;
    for(int i=0;i<n;i++)
       for(int j=0;j<n;j++)
       {
           C.a[i][j]=0;
           for(int k=0;k<n;k++)
           {
              C.a[i][j]+=A.a[i][k]*B.a[k][j]%mod;
              C.a[i][j]%=mod;
           }
       }
    return C;
}
matrix quick(matrix A,LL k)
{
    matrix E;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)E.a[i][j]=(i==j);
    while(k)
    {
        if(k&1)E=multi(E,A);
        k>>=1;
        A=multi(A,A);
    }
    return E;
}

int main()
{
    //freopen("in.txt","r",stdin);
    LL k;
    while(cin>>n>>k)
    {
        k--;
        for(int i=0;i<n;i++)scanf("%d",&a[i]);
        matrix ans;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                LL t=a[i]^a[j];
                if(t%3==0)ans.a[i][j]=1;
                else ans.a[i][j]=0;
            }
        }
        matrix temp=quick(ans,k);
        LL sum=0;
        for(int i=0;i<n;i++)
           for(int j=0;j<n;j++)sum=(sum+temp.a[i][j])%mod;
        printf("%lld\n",sum);
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iostream>
using namespace std;
#define LL long long
const LL mod=1e9+7;
const int N=1e2+6;
const int M=10005;
LL a[N];
LL b[N][N];
int n;
struct matrix
{
    LL a[N][N];
};
matrix multi(matrix A,matrix B)
{
    matrix C;
    for(int i=0;i<n;i++)
       for(int j=0;j<n;j++)
       {
           C.a[i][j]=0;
           for(int k=0;k<n;k++)
           {
              C.a[i][j]+=A.a[i][k]*B.a[k][j]%mod;
              C.a[i][j]%=mod;
           }
       }
    return C;
}
matrix quick(matrix A,LL k)
{
    matrix E;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)E.a[i][j]=(i==j);
    while(k)
    {
        if(k&1)E=multi(E,A);
        k>>=1;
        A=multi(A,A);
    }
    return E;
}

int main()
{
    //freopen("in.txt","r",stdin);
    LL k;
    while(cin>>n>>k)
    {
        k--;
        for(int i=0;i<n;i++)scanf("%d",&a[i]);
        matrix ans;

        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                LL t=(a[i]^a[j]);
                LL cnt=0;
                for(int l=0;l<63;l++)
                {
                   if(t&((LL)1<<l))cnt++;
                }
                if(cnt%3==0)ans.a[i][j]=1;
                else ans.a[i][j]=0;
            }
        }

        matrix temp=quick(ans,k);
        LL sum=0;
        for(int i=0;i<n;i++)
           for(int j=0;j<n;j++)sum=(sum+temp.a[i][j])%mod;
        printf("%lld\n",sum);
    }
    return 0;
}


//CF 691E
#include<iostream>
#include<cstdio>
#include<cstring>
#define SIZE 105
#define maxn 105
using namespace std;
const int mod=1000000007;
int n,k;
long long a[maxn];
struct matrix {
	int n;
	int m;
	long long a[SIZE][SIZE];
	matrix() {
		n=2;
		m=2;
		memset(a,0,sizeof(a));
	}
	matrix(int x,int y) {
		n=x;
		m=y;
		memset(a,0,sizeof(a));
	}
	void print() {
		for(int i=1; i<=n; i++) {
			for(int j=1; j<=m; j++) {
				printf("%d ",a[i][j]);
			}
			printf("\n");
		}
	}
	void setv(int x) {
		if(x==0) {
			memset(a,0,sizeof(a));
		}
		if(x==1) {
			memset(a,0,sizeof(a));
			for(int i=1; i<=n; i++) a[i][i]=1;
		}
	}
	friend matrix operator *(matrix x,matrix y) {
		matrix tmp=matrix(x.m,y.m);
		for(int i=1; i<=x.n; i++) {
			for(int j=1; j<=y.m; j++) {
				tmp.a[i][j]=0;
				for(int k=1; k<=y.n; k++) {
					tmp.a[i][j]+=(x.a[i][k]*y.a[k][j])%mod;
				}
				tmp.a[i][j]%=mod;
			}
		}
		return tmp;
	}
};
matrix fast_pow(matrix x,int k) {
	matrix ans=matrix(n,n);
	ans.setv(1);
	while(k>0) {
		if(k&1) {
			ans=ans*x;
		}
		k>>=1;
		x=x*x;
	}
	//ans.print();
	return ans;
}
int count_1(long long x) {
	int ans=0;
	while(x>0){
		if(x%2) ans++;
		x/=2;
	}
	return ans;
}
int main() {
	scanf("%d %d",&n,&k);
	for(int i=1; i<=n; i++) scanf("%I64d",&a[i]);
	matrix xor_mat=matrix(n,n);
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=n; j++) {
			if(count_1(a[i]^a[j])%3==0) xor_mat.a[i][j]=1;
			else xor_mat.a[i][j]=0;
		}
	}
	xor_mat=fast_pow(xor_mat,k-1);
	long long ans=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			ans=(ans+xor_mat.a[i][j])%mod;
		}
	}
	printf("%I64d\n",ans);
}


//CF 691E
#include<iostream>
#include<cstdio>
#include<cstring>
#define SIZE 105
#define maxn 105
using namespace std;
const long long mod=1000000007;
int n;
long long k;
long long num[maxn];
struct matrix {
	int n;
	int m;
	long long a[SIZE][SIZE];
	matrix() {
		n=2;
		m=2;
		memset(a,0,sizeof(a));
	}
	matrix(int x,int y) {
		n=x;
		m=y;
		memset(a,0,sizeof(a));
	}
	void print() {
		for(int i=1; i<=n; i++) {
			for(int j=1; j<=m; j++) {
				printf("%d ",a[i][j]);
			}
			printf("\n");
		}
	}
	void setv(int x) {
		if(x==0) {
			memset(a,0,sizeof(a));
		}
		if(x==1) {
			memset(a,0,sizeof(a));
			for(int i=1; i<=n; i++) a[i][i]=1;
		}
	}
	friend matrix operator *(matrix x,matrix y) {
		matrix tmp=matrix(x.n,y.m);
		for(int i=1; i<=x.n; i++) {
			for(int j=1; j<=y.m; j++) {
				tmp.a[i][j]=0;
				for(int k=1; k<=y.n; k++) {
					tmp.a[i][j]+=(x.a[i][k]*y.a[k][j])%mod;
				}
				tmp.a[i][j]%=mod;
			}
		}
		return tmp;
	}
};
matrix fast_pow(matrix x,long long k) {
	matrix ans=matrix(n,n);
	ans.setv(1);
	while(k>0) {
		if(k&1) {
			ans=ans*x;
		}
		k>>=1;
		x=x*x;
	}
	//ans.print();
	return ans;
}
long long count_1(long long x) {
	long long ans=0;
	while(x>0){
		if(x&1) ans++;
		x/=2;
	}
	return ans;
}
int main() {
	scanf("%d %I64d",&n,&k);
	for(int i=1; i<=n; i++) scanf("%I64d",&num[i]);
	matrix xor_mat=matrix(n,n);
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=n; j++) {
			if(count_1(num[i]^num[j])%3==0 )xor_mat.a[i][j]=1;
			else xor_mat.a[i][j]=0;
		}
	}
//	freopen("mat1.txt","w",stdout);
//	xor_mat.print();
	xor_mat=fast_pow(xor_mat,k-1);
	long long ans=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			ans=ans+xor_mat.a[i][j];
		}
		ans%=mod;
	}
	printf("%I64d\n",ans);
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <deque>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <complex>
#include <cstring>
#include <bitset>
//#include "sdf.hpp"

using namespace std;
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define repd(i, a, b) for(int i = (a); i > (b); i--)
#define forIt(it, a) for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define forRev(it, a) for(__typeof((a).rbegin()) it = (a).rbegin(); it != (a).rend(); it++)
#define ft(a) __typeof((a).begin())
#define ll long long
#define ld long double
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define sz(a) (a).size()
#define all(a) (a).begin(), (a).end()
#define Rep(i,n) for(int i = 0; i < (n); ++i)

typedef complex<ld> cplex;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int N = 100 + 7;
const int M = 18;
const int mid = M / 2;
const int mod = 1e9 + 9;
const int inf = 1e9 + 7;
const ll linf = 1ll * inf * inf;
const double pi = acos(-1);
const double eps = 1e-7;
const double ep = 1e-5;
const int maxn = 1e5 + 7;
const double PI = acos(-1);

struct matrix{
    ll a[N][N];
    int n, m;
    matrix(int _n, int _m){
        n = _n;
        m = _m;
        memset(a, 0, sizeof(a));
    }

    matrix operator*(matrix u){
        matrix c(n, u.m);
        for(int i = 1; i <= c.n; i++){
            for(int j = 1; j <= c.m; j++){
                ll tmp = 0;
                for(int t = 1; t <= m; t++)
                    tmp = (tmp + (ll)a[i][t] * u.a[t][j]) % inf;
                c.a[i][j] = tmp;
            }
        }
        return c;
    }
    void print() {
        for(int i = 1; i <= n; ++i) {
            for(int j = 1; j <= m; ++j)
                printf("%d ", a[i][j]);
            printf("\n");
        }
    }
};

bool ok(ll x, ll y) {
    x ^= y;
    int cnt =0 ;
    while (x > 0) {
        cnt += (x & 1);
        x >>= 1;
    }
    return (cnt % 3 == 0);
}

ll a[N], k;
int n;

void solve() {
    cin >> n >> k;
    rep(i, 1, n + 1) cin >> a[i];

    matrix b(n, n);

    rep(i, 1, n + 1) {
        rep(j, 1, n + 1) {
            if (ok(a[i], a[j])) {
                b.a[j][i] = 1;
            }
        }
    }
    //b.print();
    --k;

    matrix I(n, n);
    rep(i, 1, n + 1) I.a[i][i] = 1;
    while (k > 0) {
        if (k & 1) {
            I = I * b;
        }
        b = b * b;
        k >>= 1;
    }

    matrix res(1, n);
    rep(i, 1, n + 1) res.a[1][i] = 1;

    res = res * I;
    ll ans = 0;
    rep(i, 1, n + 1) ans = (ans + res.a[1][i]) % inf;
    cout << ans;
}

void solve2() {
    string s;
    cin >> s;
    int n = s.size();
    int i = 0, j = n - 1;
    while (i < sz(s) && s[i] == '0') ++i;
    while (j >= 0 && s[j] == '0') --j;

    if (i > j) {
        puts("0");
        return;
    }

}

int main() {
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
    int T = 1;
    //    cin >> T;
    rep(i, 1, T + 1) {
        //printf("Case #%d: ", i);

        solve();
    }

}


#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <deque>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <complex>
#include <cstring>
#include <bitset>
//#include "sdf.hpp"

using namespace std;
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define repd(i, a, b) for(int i = (a); i > (b); i--)
#define forIt(it, a) for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define forRev(it, a) for(__typeof((a).rbegin()) it = (a).rbegin(); it != (a).rend(); it++)
#define ft(a) __typeof((a).begin())
#define ll long long
#define ld long double
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define sz(a) (a).size()
#define all(a) (a).begin(), (a).end()
#define Rep(i,n) for(int i = 0; i < (n); ++i)

typedef complex<ld> cplex;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int N = 100 + 7;
const int M = 18;
const int mid = M / 2;
const int mod = 1e9 + 9;
const int inf = 1e9 + 7;
const ll linf = 1ll * inf * inf;
const double pi = acos(-1);
const double eps = 1e-7;
const double ep = 1e-5;
const int maxn = 1e5 + 7;
const double PI = acos(-1);

struct matrix{
    ll a[N][N];
    int n, m;
    matrix(int _n, int _m){
        n = _n;
        m = _m;
        memset(a, 0, sizeof(a));
    }

    matrix operator*(matrix u){
        matrix c(n, u.m);
        for(int i = 1; i <= c.n; i++){
            for(int j = 1; j <= c.m; j++){
                ll tmp = 0;
                for(int t = 1; t <= m; t++)
                    tmp = (tmp + (ll)a[i][t] * u.a[t][j]) % inf;
                c.a[i][j] = tmp;
            }
        }
        return c;
    }
    void print() {
        for(int i = 1; i <= n; ++i) {
            for(int j = 1; j <= m; ++j)
                printf("%d ", a[i][j]);
            printf("\n");
        }
    }
};

ll a[N], k;
ll n;

void solve() {
    cin >> n >> k;
    rep(i, 1, n + 1) cin >> a[i];

    matrix b(n, n);

    rep(i, 1, n + 1) {
        rep(j, 1, n + 1) {
            if ((a[i] ^ a[j]) % 3 == 0) {
                b.a[j][i] = 1;
            }
        }
    }
    --k;

    matrix I(n, n);
    rep(i, 1, n + 1) I.a[i][i] = 1;
    while (k > 0) {
        if (k & 1) {
            I = I * b;
        }
        b = b * b;
        k >>= 1;
    }

    matrix res(1, n);
    rep(i, 1, n + 1) res.a[1][i] = 1;

    res = res * I;
    ll ans = 0;
    rep(i, 1, n + 1) ans = (ans + res.a[1][i]);
    cout << ans;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
    int T = 1;
    //    cin >> T;
    rep(i, 1, T + 1) {
        //printf("Case #%d: ", i);

        solve();
    }

}


#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <deque>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <complex>
#include <cstring>
#include <bitset>
//#include "sdf.hpp"

using namespace std;
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define repd(i, a, b) for(int i = (a); i > (b); i--)
#define forIt(it, a) for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define forRev(it, a) for(__typeof((a).rbegin()) it = (a).rbegin(); it != (a).rend(); it++)
#define ft(a) __typeof((a).begin())
#define ll long long
#define ld long double
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define sz(a) (a).size()
#define all(a) (a).begin(), (a).end()
#define Rep(i,n) for(int i = 0; i < (n); ++i)

typedef complex<ld> cplex;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int N = 100 + 7;
const int M = 18;
const int mid = M / 2;
const int mod = 1e9 + 9;
const int inf = 1e9 + 7;
const ll linf = 1ll * inf * inf;
const double pi = acos(-1);
const double eps = 1e-7;
const double ep = 1e-5;
const int maxn = 1e5 + 7;
const double PI = acos(-1);

struct matrix{
    ll a[N][N];
    int n, m;
    matrix(int _n, int _m){
        n = _n;
        m = _m;
        memset(a, 0, sizeof(a));
    }

    matrix operator*(matrix u){
        matrix c(n, u.m);
        for(int i = 1; i <= c.n; i++){
            for(int j = 1; j <= c.m; j++){
                ll tmp = 0;
                for(int t = 1; t <= m; t++)
                    tmp = (tmp + (ll)a[i][t] * u.a[t][j]) % inf;
                c.a[i][j] = tmp;
            }
        }
        return c;
    }
    void print() {
        for(int i = 1; i <= n; ++i) {
            for(int j = 1; j <= m; ++j)
                printf("%d ", a[i][j]);
            printf("\n");
        }
    }
};

bool ok(ll x, ll y) {
    x ^= y;
    int cnt =0 ;
    while (x > 0) {
        cnt += (x & 1);
        x >>= 1;
    }
    return (cnt % 3 == 0);
}

ll a[N], k;
ll n;

void solve() {
    cin >> n >> k;
    rep(i, 1, n + 1) cin >> a[i];

    matrix b(n, n);

    rep(i, 1, n + 1) {
        rep(j, 1, n + 1) {
            if (ok(a[i], a[j])) {
                b.a[j][i] = 1;
            }
        }
    }
    --k;

    matrix I(n, n);
    rep(i, 1, n + 1) I.a[i][i] = 1;
    while (k > 0) {
        if (k & 1) {
            I = I * b;
        }
        b = b * b;
        k >>= 1;
    }

    matrix res(1, n);
    rep(i, 1, n + 1) res.a[1][i] = 1;

    res = res * I;
    ll ans = 0;
    rep(i, 1, n + 1) ans = (ans + res.a[1][i]);
    cout << ans;
}

//void solve2() {
//    string s;
//    cin >> s;
////    s =
//}

int main() {
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
    int T = 1;
    //    cin >> T;
    rep(i, 1, T + 1) {
        //printf("Case #%d: ", i);

        solve();
    }

}


#include <bits/stdc++.h>
#define FOR(i, l, r) for (int i = int(l); i < int(r); i++)
#define STRUCT3(NAME, v1, v2, v3, name) typedef struct NAME \
        {   \
            int v1, v2, v3; \
            NAME(int v1 = 0, int v2 = 0, int v3 = 0) : v1(v1), v2(v2), v3(v3) {} \
            friend bool operator < (const NAME& athis, const NAME& other) \
            {   \
                if (athis.v1 != other.v1) return athis.v1 < other.v1;   \
                if (athis.v2 != other.v2) return athis.v2 < other.v2;   \
                return athis.v3 < other.v3;   \
            }\
        }name;
#define FST first
#define SCD second
#define modp 1000000007
#define EPS 1e-7
#define MAXN 103
using namespace std;
typedef long long LL;
typedef unsigned int UI;

int N;
LL K;
LL a[MAXN];
LL dp[65][MAXN][MAXN];
int G[MAXN][MAXN];
LL res[65][MAXN][MAXN];
int cnt(LL x)
{
    int res = 0;
    while (x) {
        res += x & 1;
        x >>= 1;
    }
    return res;
}

int main()
{
    scanf("%d%I64d", &N, &K);
    FOR(i, 0, N) {
        scanf("%I64d", a + i);
    }
    FOR(i, 0, N) {
        G[i][i] = 1;
        dp[0][i][i] = 1;
        FOR(j, 0, i) {
            LL x = a[i] ^ a[j];
            if (cnt(x) % 3 == 0) {
                G[i][j] = G[j][i] = 1;
            }
        }
    }
    int t = -1;
    if (K & 1) {
        t = 0;
        FOR(i, 0, N) {
            res[0][i][i] = 1;
        }
    }
    for (int k = 1; (1ll << k) <= K; k++) {
        FOR(i, 0, N) {
            FOR(j, 0, N) {
                FOR(x, 0, N) {
                    FOR(y, 0, N) {
                        if (G[x][y]) {
                            dp[k][i][j] += dp[k - 1][i][x] * dp[k - 1][y][j] % modp;
                            dp[k][i][j] %= modp;
                        }
                    }
                }
                if ((K >> k) & 1) {
                    if (t == -1) {
                        res[k][i][j] = dp[k][i][j];
                    }
                    else {
                        FOR(x, 0, N) {
                            FOR(y, 0, N) {
                                res[k][i][j] += res[t][i][x] * dp[k][y][j] % modp;
                                res[k][i][j] %= modp;
                            }
                        }
                    }
                }
            }
        }
        if ((K >> k) & 1) {
            t = k;
        }
    }
    LL ans = 0;
    FOR(i, 0, N) {
        FOR(j, 0, N) {
            ans += res[t][i][j];
            ans %= modp;
        }
    }
    printf("%I64d\n", ans);
    return 0;
}


#include <bits/stdc++.h>
#define FOR(i, l, r) for (int i = int(l); i < int(r); i++)
#define STRUCT3(NAME, v1, v2, v3, name) typedef struct NAME \
        {   \
            int v1, v2, v3; \
            NAME(int v1 = 0, int v2 = 0, int v3 = 0) : v1(v1), v2(v2), v3(v3) {} \
            friend bool operator < (const NAME& athis, const NAME& other) \
            {   \
                if (athis.v1 != other.v1) return athis.v1 < other.v1;   \
                if (athis.v2 != other.v2) return athis.v2 < other.v2;   \
                return athis.v3 < other.v3;   \
            }\
        }name;
#define FST first
#define SCD second
#define modp 1000000007
#define EPS 1e-7
#define MAXN 103
using namespace std;
typedef long long LL;
typedef unsigned int UI;

int N;
typedef struct MAT
{
    LL dat[MAXN][MAXN];
    MAT()
    {
        memset(dat, 0, sizeof(dat));
    }
    MAT operator * (const MAT& other)
    {
        MAT res;
        FOR(i, 0, N) FOR(j, 0, N) FOR(k, 0, N) {
            res.dat[i][j] += dat[i][k] * other.dat[k][j] % modp;
            res.dat[i][j] %= modp;
        }
        return res;
    }
}Mat;
LL K;
LL a[MAXN];
Mat dp[2];
Mat G;
Mat res[2];
int cnt(LL x)
{
    int res = 0;
    while (x) {
        res += x & 1;
        x >>= 1;
    }
    return res;
}

int main()
{
    scanf("%d%I64d", &N, &K);
//    N = 100;
//    K = 1e18;
    Mat *newdp, *olddp;
    Mat *newres, *oldres;
    FOR(i, 0, N) {
        scanf("%I64d", a + i);
//        a[i] = 1;
    }
    FOR(i, 0, N) {
        G.dat[i][i] = 1;
        dp[0].dat[i][i] = 1;
        FOR(j, 0, i) {
            LL x = a[i] ^ a[j];
            if (cnt(x) % 3 == 0) {
                G.dat[i][j] = G.dat[j][i] = 1;
            }
        }
    }
    olddp = dp;
    newdp = dp + 1;
    int t = -1;
    if (K & 1) {
        t = 0;
        FOR(i, 0, N) {
            res[0].dat[i][i] = 1;
        }
    }
    oldres = res;
    newres = res + 1;
    for (int k = 1; (1ll << k) <= K; k++) {
        *newdp = *olddp * G * *olddp;
        if ((K >> k) & 1) {
            if (t == -1) {
                *newres = *newdp;
            }
            else {
                *newres = *oldres * G * *newdp;
            }
            t = k;
            swap(newres, oldres);
        }
        swap(newdp, olddp);
    }
    LL ans = 0;
    FOR(i, 0, N) {
        FOR(j, 0, N) {
            ans += oldres -> dat[i][j];
            ans %= modp;
        }
    }
    printf("%I64d\n", ans);
    return 0;
}


#include <bits/stdc++.h>
#define FOR(i, l, r) for (int i = int(l); i < int(r); i++)
#define STRUCT3(NAME, v1, v2, v3, name) typedef struct NAME \
        {   \
            int v1, v2, v3; \
            NAME(int v1 = 0, int v2 = 0, int v3 = 0) : v1(v1), v2(v2), v3(v3) {} \
            friend bool operator < (const NAME& athis, const NAME& other) \
            {   \
                if (athis.v1 != other.v1) return athis.v1 < other.v1;   \
                if (athis.v2 != other.v2) return athis.v2 < other.v2;   \
                return athis.v3 < other.v3;   \
            }\
        }name;
#define FST first
#define SCD second
#define modp 1000000007
#define EPS 1e-7
#define MAXN 103
using namespace std;
typedef long long LL;
typedef unsigned int UI;

int N;
typedef struct MAT
{
    LL dat[MAXN][MAXN];
    MAT()
    {
        memset(dat, 0, sizeof(dat));
    }
    MAT operator * (const MAT& other)
    {
        MAT res;
        FOR(i, 0, N) FOR(j, 0, N) FOR(k, 0, N) {
            res.dat[i][j] += dat[i][k] * other.dat[k][j] % modp;
            res.dat[i][j] %= modp;
        }
        return res;
    }
}Mat;
LL K;
LL a[MAXN];
Mat G;
Mat res;
int cnt(LL x)
{
    int res = 0;
    while (x) {
        res += x & 1;
        x >>= 1;
    }
    return res;
}
Mat mpow(Mat& A, LL k)
{
    Mat res;
    FOR(i, 0, N) {
        res.dat[i][i] = 1;
    }
    while (k) {
        if (k & 1) {
            res = res * G;
        }
        G = G * G;
        k >>= 1;
    }
    return res;
}

int main()
{
    scanf("%d%I64d", &N, &K);
//    N = 100;
//    K = 1e18;
    FOR(i, 0, N) {
        scanf("%I64d", a + i);
//        a[i] = 1;
    }
    FOR(i, 0, N) {
        G.dat[i][i] = 1;
        FOR(j, 0, i) {
            LL x = a[i] ^ a[j];
            if (cnt(x) % 3 == 0) {
                G.dat[i][j] = G.dat[j][i] = 1;
            }
        }
    }
    res = mpow(G, K - 1);
    LL ans = 0;
    FOR(i, 0, N) {
        FOR(j, 0, N) {
            ans += res.dat[i][j];
            ans %= modp;
        }
    }
    printf("%I64d\n", ans);
    return 0;
}


#include <bits/stdc++.h>
#define FOR(i, l, r) for (int i = int(l); i < int(r); i++)
#define STRUCT3(NAME, v1, v2, v3, name) typedef struct NAME \
        {   \
            int v1, v2, v3; \
            NAME(int v1 = 0, int v2 = 0, int v3 = 0) : v1(v1), v2(v2), v3(v3) {} \
            friend bool operator < (const NAME& athis, const NAME& other) \
            {   \
                if (athis.v1 != other.v1) return athis.v1 < other.v1;   \
                if (athis.v2 != other.v2) return athis.v2 < other.v2;   \
                return athis.v3 < other.v3;   \
            }\
        }name;
#define FST first
#define SCD second
#define modp 1000000007
#define EPS 1e-7
#define MAXN 103
using namespace std;
typedef long long LL;
typedef unsigned int UI;

int N;
typedef struct MAT
{
    LL dat[MAXN][MAXN];
    MAT()
    {
        memset(dat, 0, sizeof(dat));
    }
    MAT operator * (const MAT& other)
    {
        MAT res;
        FOR(i, 0, N) FOR(j, 0, N) FOR(k, 0, N) {
            res.dat[i][j] += dat[i][k] * other.dat[k][j] % modp;
            res.dat[i][j] %= modp;
        }
        return res;
    }
}Mat;
LL K;
LL a[MAXN];
Mat dp[65];
Mat G;
Mat res;
int cnt(LL x)
{
    int res = 0;
    while (x) {
        res += x & 1;
        x >>= 1;
    }
    return res;
}

int main()
{
//    scanf("%d%I64d", &N, &K);
    N = 100;
    K = 1e18;
    FOR(i, 0, N) {
//        scanf("%I64d", a + i);
        a[i] = 1;
    }
    FOR(i, 0, N) {
        G.dat[i][i] = 1;
        dp[0].dat[i][i] = 1;
        FOR(j, 0, i) {
            LL x = a[i] ^ a[j];
            if (cnt(x) % 3 == 0) {
                G.dat[i][j] = G.dat[j][i] = 1;
            }
        }
    }
    int t = -1;
    if (K & 1) {
        t = 0;
        FOR(i, 0, N) {
            res.dat[i][i] = 1;
        }
    }
    for (int k = 1; (1ll << k) <= K; k++) {
        dp[k] = dp[k - 1] * G * dp[k - 1];
        if ((K >> k) & 1) {
            if (t == -1) {
                res = dp[k];
            }
            else {
                res = res * G * dp[k];
            }
            t = k;
        }
    }
    LL ans = 0;
    FOR(i, 0, N) {
        FOR(j, 0, N) {
            ans += res.dat[i][j];
            ans %= modp;
        }
    }
    printf("%I64d\n", ans);
    return 0;
}


#include <bits/stdc++.h>
#define FOR(i, l, r) for (int i = int(l); i < int(r); i++)
#define STRUCT3(NAME, v1, v2, v3, name) typedef struct NAME \
        {   \
            int v1, v2, v3; \
            NAME(int v1 = 0, int v2 = 0, int v3 = 0) : v1(v1), v2(v2), v3(v3) {} \
            friend bool operator < (const NAME& athis, const NAME& other) \
            {   \
                if (athis.v1 != other.v1) return athis.v1 < other.v1;   \
                if (athis.v2 != other.v2) return athis.v2 < other.v2;   \
                return athis.v3 < other.v3;   \
            }\
        }name;
#define FST first
#define SCD second
#define modp 1000000007
#define EPS 1e-7
#define MAXN 103
using namespace std;
typedef long long LL;
typedef unsigned int UI;

int N;
LL K;
LL a[MAXN];
LL dp[65][MAXN][MAXN];
int G[MAXN][MAXN];
LL res[65][MAXN][MAXN];
int cnt(LL x)
{
    int res = 0;
    while (x) {
        res += x & 1;
        x >>= 1;
    }
    return res;
}

int main()
{
    scanf("%d%I64d", &N, &K);
    FOR(i, 0, N) {
        scanf("%I64d", a + i);
    }
    FOR(i, 0, N) {
        G[i][i] = 1;
        dp[0][i][i] = 1;
        FOR(j, 0, i) {
            int x = a[i] ^ a[j];
            if (cnt(x) % 3 == 0) {
                G[i][j] = G[j][i] = 1;
            }
        }
    }
    int t = -1;
    if (K & 1) {
        t = 0;
        FOR(i, 0, N) {
            res[0][i][i] = 1;
        }
    }
    for (int k = 1; (1ll << k) <= K; k++) {
        FOR(i, 0, N) {
            FOR(j, 0, N) {
                FOR(x, 0, N) {
                    FOR(y, 0, N) {
                        if (G[x][y]) {
                            dp[k][i][j] += dp[k - 1][i][x] * dp[k - 1][y][j] % modp;
                            dp[k][i][j] %= modp;
                        }
                    }
                }
                if ((K >> k) & 1) {
                    if (t == -1) {
                        res[k][i][j] = dp[k][i][j];
                    }
                    else {
                        FOR(x, 0, N) {
                            FOR(y, 0, N) {
                                res[k][i][j] += res[t][i][x] * dp[k][y][j] % modp;
                                res[k][i][j] %= modp;
                            }
                        }
                    }
                }
            }
        }
        if ((K >> k) & 1) {
            t = k;
        }
    }
    LL ans = 0;
    FOR(i, 0, N) {
        FOR(j, 0, N) {
            ans += res[t][i][j];
            ans %= modp;
        }
    }
    printf("%I64d\n", ans);
    return 0;
}


using namespace std;
#include<bits/stdc++.h>
typedef long long   LL;
typedef long long   ll;
typedef   pair<LL,LL>  PII;
typedef   vector< PII > VPII;
typedef   vector<long long>   VI;
typedef   map<string,LL>  MSI;
typedef   map<LL,LL>  MII;
///Print
#define R(n)       scanf("%lld", &n)
#define P(a)  printf("%lld\n",a)
#define NL printf("\n")
#define case(no) printf("Case %lld: ",++no)
#define casenl(no) printf("Case %lld:\n",++no)
///LOOP
#define rep(x,n) for(__typeof(n) x=0;x<(n);x++)
#define reps(i,x) for(int  i=0;i<(x.size());i++)
#define repp(x,n) for(__typeof(n) x=1;x<=(n);x++)
#define FORSTL(x,n) for(__typeof(n.begin()) x=n.begin();x!=n.end();x++)
///Shortcut
#define mem(ar,value) memset(ar,value,sizeof(ar))
#define all(x) x.begin(),x.end()
#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())
#define len(s) s.size()
#define mp make_pair
#define pb push_back
#define FF first
#define SS second
#define LB(a,x) (lower_bound(all(a),x)-a.begin()) ///first element in the range [first,last) which does not compare less than val.
#define UB(a,x) (upper_bound(all(a),x)-a.begin()) ///first element in the range [first,last) which compares greater than val.
#define MOD 1e9+7
///Min AND Max
#define MIN3(a,b,c) min(a,min(b,c))
#define MAX3(a,b,c) max(a,max(b,c))
#define EPS (1e-9)
#define PI acos(-1.0)
#define isEq(a,b) (fabs((a)-(b))<eps)
#define Fast ios_base::sync_with_stdio(false); cin.tie(false);
///DEBUG
#define D(x) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<endl;
#define DD(x,y) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<" | "#y" = "<<y<<endl;
#define DDD(x,y,z) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<" | "#y" = "<<y<<" | "#z" ="<<z<<endl;
///Gcd and Lcm
template<class T>T gcd(T a,T b){return b == 0 ? a : gcd(b, a % b);}
template<typename T>T lcm(T a, T b) {return a / gcd(a,b) * b;}
///Bigmod && Pow
template<class T>T my_pow(T n,T p){if(p==0)return 1;T x=my_pow(n,p/2);x=(x*x);if(p&1)x=(x*n);return x;} ///n to the power p
template<class T>T big_mod(T n,T p,T m){if(p==0)return (T)1;T x=big_mod(n,p/2,m);x=(x*x)%m;if(p&1)x=(x*n)%m;return x;}
///string to int
template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}///
string itos(LL n){string s;while(n){s+=(n%10+48);n/=10;}reverse(all(s));return s;}
LL stoi(string s){LL n=0;rep(i,len(s))n=n*10+(s[i]-48);return n;}
/// geometry
double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}
template<typename T> T DIS(T x1,T y1,T x2, T y2){return sqrt( (double)( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ) );}
template<typename T> T ANGLE(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template<typename T> LL isLeft(T a,T b,T c) { return (c.x-a.x)*(b.y-a.y)-(b.x-a.x)*(c.y-a.y); }
//struct info{LL x,y;}arr[100005];bool com(info a,info b){return (a.x<b.x) or (a.x==b.x and a.y<b.y);}
LL ar[102],br[102];
LL a=0,b=0,c=0,r=0,rr=0,res=0,n,m,t=0,ks=0,k;
string  s;

struct info
{
    LL m[105][105];
}base,kk,dd;

info mul(info aa,info bb)
{

    info mat;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            mat.m[i][j]=0;

            for(int k=0;k<n;k++)
            {
                mat.m[i][j]+=(aa.m[i][k]*bb.m[k][j])%1000000007;

                mat.m[i][j]%=1000000007;
            }
        }
    }

    return mat;
}

int main()
{
    //Fast;

    cin>>n;cin>>k;

    if(k==1)
    {
        cout<<n;

        return 0;
    }

    rep(i,n)  cin>>ar[i];

    rep(i,n)
    {
        rep(j,n)
        {
            LL aa=ar[i]^ar[j];

            if(__builtin_popcount(aa)%3==0)base.m[i][j]=1;
            else  base.m[i][j]=0;
        }
    }

    k--;
    info ans=base;
    k--;

    while(k>0)
    {
        if(k%2==1)
        {

            ans=mul(ans,base);

        }

        base=mul(base,base);
        k/=2;
    }

    rep(i,n)
    {
        rep(j,n)
        {
            r+=ans.m[i][j];

          r%=1000000007;
        }
    }
    cout<<r;

   return 0;

}


using namespace std;
#include<bits/stdc++.h>
typedef long long   LL;
typedef long long   ll;
typedef   pair<LL,LL>  PII;
typedef   vector< PII > VPII;
typedef   vector<long long>   VI;
typedef   map<string,LL>  MSI;
typedef   map<LL,LL>  MII;
///Print
#define R(n)       scanf("%lld", &n)
#define P(a)  printf("%lld\n",a)
#define NL printf("\n")
#define case(no) printf("Case %lld: ",++no)
#define casenl(no) printf("Case %lld:\n",++no)
///LOOP
#define rep(x,n) for(__typeof(n) x=0;x<(n);x++)
#define reps(i,x) for(int  i=0;i<(x.size());i++)
#define repp(x,n) for(__typeof(n) x=1;x<=(n);x++)
#define FORSTL(x,n) for(__typeof(n.begin()) x=n.begin();x!=n.end();x++)
///Shortcut
#define mem(ar,value) memset(ar,value,sizeof(ar))
#define all(x) x.begin(),x.end()
#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())
#define len(s) s.size()
#define mp make_pair
#define pb push_back
#define FF first
#define SS second
#define LB(a,x) (lower_bound(all(a),x)-a.begin()) ///first element in the range [first,last) which does not compare less than val.
#define UB(a,x) (upper_bound(all(a),x)-a.begin()) ///first element in the range [first,last) which compares greater than val.
///Min AND Max
#define MIN3(a,b,c) min(a,min(b,c))
#define MAX3(a,b,c) max(a,max(b,c))
#define EPS (1e-9)
#define PI acos(-1.0)
#define isEq(a,b) (fabs((a)-(b))<eps)
#define Fast ios_base::sync_with_stdio(false); cin.tie(false);
///DEBUG
#define D(x) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<endl;
#define DD(x,y) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<" | "#y" = "<<y<<endl;
#define DDD(x,y,z) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<" | "#y" = "<<y<<" | "#z" ="<<z<<endl;
///Gcd and Lcm
template<class T>T gcd(T a,T b){return b == 0 ? a : gcd(b, a % b);}
template<typename T>T lcm(T a, T b) {return a / gcd(a,b) * b;}
///Bigmod && Pow
template<class T>T my_pow(T n,T p){if(p==0)return 1;T x=my_pow(n,p/2);x=(x*x);if(p&1)x=(x*n);return x;} ///n to the power p
template<class T>T big_mod(T n,T p,T m){if(p==0)return (T)1;T x=big_mod(n,p/2,m);x=(x*x)%m;if(p&1)x=(x*n)%m;return x;}
///string to int
template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}///
string itos(LL n){string s;while(n){s+=(n%10+48);n/=10;}reverse(all(s));return s;}
LL stoi(string s){LL n=0;rep(i,len(s))n=n*10+(s[i]-48);return n;}
/// geometry
double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}
template<typename T> T DIS(T x1,T y1,T x2, T y2){return sqrt( (double)( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ) );}
template<typename T> T ANGLE(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template<typename T> LL isLeft(T a,T b,T c) { return (c.x-a.x)*(b.y-a.y)-(b.x-a.x)*(c.y-a.y); }
const long long int MOD=1e9+7;
//struct info{LL x,y;}arr[100005];bool com(info a,info b){return (a.x<b.x) or (a.x==b.x and a.y<b.y);}
LL ar[1002],br[1002];
LL a=0,b=0,c=0,r=0,rr=0,res=0,n,t=0,ks=0,k;
string  s;

struct info
{
    LL m[105][105];
}base,kk,dd;

info mul(info aa,info bb)
{

    info mat;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            mat.m[i][j]=0;
            for(int k=0;k<n;k++)
            {
                mat.m[i][j]=(mat.m[i][j]+(aa.m[i][k]*bb.m[k][j])%MOD)% MOD;
            }
        }
    }

    return mat;
}

int main()
{
    //Fast;

    cin>>n;cin>>k;

    if(k==1)
    {
        cout<<n;

        return 0;
    }

    rep(i,n)  cin>>ar[i];

    rep(i,n)
    {
        rep(j,n)
        {
            LL aa=ar[i]^ar[j];
            LL dd=__builtin_popcount(aa);
            if(dd%3==0)base.m[i][j]=1;
        }
    }

    k--;
    info ans=base;
    k--;
    while(k>0)
    {
        if(k%2==1)
        {
            ans=mul(ans,base);
        }
        base=mul(base,base);
        k/=2;
    }

    rep(i,n)
    {
        rep(j,n)
        {
            r+=ans.m[i][j];

          r%=MOD;
        }
    }
    cout<<r;

   return 0;

}


using namespace std;
#include<bits/stdc++.h>
typedef long long   LL;
typedef long long   ll;
typedef   pair<LL,LL>  PII;
typedef   vector< PII > VPII;
typedef   vector<long long>   VI;
typedef   map<string,LL>  MSI;
typedef   map<LL,LL>  MII;
///Print
#define R(n)       scanf("%lld", &n)
#define P(a)  printf("%lld\n",a)
#define NL printf("\n")
#define case(no) printf("Case %lld: ",++no)
#define casenl(no) printf("Case %lld:\n",++no)
///LOOP
#define rep(x,n) for(__typeof(n) x=0;x<(n);x++)
#define reps(i,x) for(int  i=0;i<(x.size());i++)
#define repp(x,n) for(__typeof(n) x=1;x<=(n);x++)
#define FORSTL(x,n) for(__typeof(n.begin()) x=n.begin();x!=n.end();x++)
///Shortcut
#define mem(ar,value) memset(ar,value,sizeof(ar))
#define all(x) x.begin(),x.end()
#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())
#define len(s) s.size()
#define mp make_pair
#define pb push_back
#define FF first
#define SS second
#define LB(a,x) (lower_bound(all(a),x)-a.begin()) ///first element in the range [first,last) which does not compare less than val.
#define UB(a,x) (upper_bound(all(a),x)-a.begin()) ///first element in the range [first,last) which compares greater than val.
///Min AND Max
#define MIN3(a,b,c) min(a,min(b,c))
#define MAX3(a,b,c) max(a,max(b,c))
#define EPS (1e-9)
#define PI acos(-1.0)
#define isEq(a,b) (fabs((a)-(b))<eps)
#define Fast ios_base::sync_with_stdio(false); cin.tie(false);
///DEBUG
#define D(x) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<endl;
#define DD(x,y) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<" | "#y" = "<<y<<endl;
#define DDD(x,y,z) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<" | "#y" = "<<y<<" | "#z" ="<<z<<endl;
///Gcd and Lcm
template<class T>T gcd(T a,T b){return b == 0 ? a : gcd(b, a % b);}
template<typename T>T lcm(T a, T b) {return a / gcd(a,b) * b;}
///Bigmod && Pow
template<class T>T my_pow(T n,T p){if(p==0)return 1;T x=my_pow(n,p/2);x=(x*x);if(p&1)x=(x*n);return x;} ///n to the power p
template<class T>T big_mod(T n,T p,T m){if(p==0)return (T)1;T x=big_mod(n,p/2,m);x=(x*x)%m;if(p&1)x=(x*n)%m;return x;}
///string to int
template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}///
string itos(LL n){string s;while(n){s+=(n%10+48);n/=10;}reverse(all(s));return s;}
LL stoi(string s){LL n=0;rep(i,len(s))n=n*10+(s[i]-48);return n;}
/// geometry
double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}
template<typename T> T DIS(T x1,T y1,T x2, T y2){return sqrt( (double)( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ) );}
template<typename T> T ANGLE(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template<typename T> LL isLeft(T a,T b,T c) { return (c.x-a.x)*(b.y-a.y)-(b.x-a.x)*(c.y-a.y); }
const long long int MOD=1e9+7;
//struct info{LL x,y;}arr[100005];bool com(info a,info b){return (a.x<b.x) or (a.x==b.x and a.y<b.y);}
LL ar[1002],br[1002];
LL a=0,b=0,c=0,r=0,rr=0,res=0,n,t=0,ks=0,k;
string  s;
struct info
{
    LL m[105][105];
}base;
info multi(info aa,info bb)
{

    info mat;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            mat.m[i][j]=0;
            LL tot=0;
            for(int k=0;k<n;k++)
            {
               tot=(tot+(aa.m[i][k]*bb.m[k][j])%MOD)% MOD;

            }
             mat.m[i][j]=tot;
        }

    }

    return mat;
}

info bigmod(info ee,LL k)
{
     info ans=ee;
    k--;
    while(k>0)
    {
        if(k&1)
        {
            ans=multi(ans,ee);
        }
        ee=multi(ee,ee);
        k/=2;
    }

    return ans;

}

int main()
{
    //Fast;
    cin>>n;cin>>k;
    rep(i,n)  cin>>ar[i];
    rep(i,n)
    {
        rep(j,n)
        {
            LL aa=ar[i]^ar[j];
            int  dd=__builtin_popcountll(aa);
            if(dd%3==0)base.m[i][j]=1;
        }
    }
    if(k==1)
    {
        cout<<n;
        return 0;
    }
    info ans=bigmod( base,k-1);
    rep(i,n)
    {
        rep(j,n)
        {
         r+=ans.m[i][j];
          r%=MOD;
        }
    }
    cout<<r;

   return 0;

}


using namespace std;
#include<bits/stdc++.h>
typedef long long   LL;
typedef long long   ll;
typedef   pair<LL,LL>  PII;
typedef   vector< PII > VPII;
typedef   vector<long long>   VI;
typedef   map<string,LL>  MSI;
typedef   map<LL,LL>  MII;
///Print
#define R(n)       scanf("%lld", &n)
#define P(a)  printf("%lld\n",a)
#define NL printf("\n")
#define case(no) printf("Case %lld: ",++no)
#define casenl(no) printf("Case %lld:\n",++no)
///LOOP
#define rep(x,n) for(__typeof(n) x=0;x<(n);x++)
#define reps(i,x) for(int  i=0;i<(x.size());i++)
#define repp(x,n) for(__typeof(n) x=1;x<=(n);x++)
#define FORSTL(x,n) for(__typeof(n.begin()) x=n.begin();x!=n.end();x++)
///Shortcut
#define mem(ar,value) memset(ar,value,sizeof(ar))
#define all(x) x.begin(),x.end()
#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())
#define len(s) s.size()
#define mp make_pair
#define pb push_back
#define FF first
#define SS second
#define LB(a,x) (lower_bound(all(a),x)-a.begin()) ///first element in the range [first,last) which does not compare less than val.
#define UB(a,x) (upper_bound(all(a),x)-a.begin()) ///first element in the range [first,last) which compares greater than val.
///Min AND Max
#define MIN3(a,b,c) min(a,min(b,c))
#define MAX3(a,b,c) max(a,max(b,c))
#define EPS (1e-9)
#define PI acos(-1.0)
#define isEq(a,b) (fabs((a)-(b))<eps)
#define Fast ios_base::sync_with_stdio(false); cin.tie(false);
///DEBUG
#define D(x) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<endl;
#define DD(x,y) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<" | "#y" = "<<y<<endl;
#define DDD(x,y,z) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<" | "#y" = "<<y<<" | "#z" ="<<z<<endl;
///Gcd and Lcm
template<class T>T gcd(T a,T b){return b == 0 ? a : gcd(b, a % b);}
template<typename T>T lcm(T a, T b) {return a / gcd(a,b) * b;}
///Bigmod && Pow
template<class T>T my_pow(T n,T p){if(p==0)return 1;T x=my_pow(n,p/2);x=(x*x);if(p&1)x=(x*n);return x;} ///n to the power p
template<class T>T big_mod(T n,T p,T m){if(p==0)return (T)1;T x=big_mod(n,p/2,m);x=(x*x)%m;if(p&1)x=(x*n)%m;return x;}
///string to int
template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}///
string itos(LL n){string s;while(n){s+=(n%10+48);n/=10;}reverse(all(s));return s;}
LL stoi(string s){LL n=0;rep(i,len(s))n=n*10+(s[i]-48);return n;}
/// geometry
double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}
template<typename T> T DIS(T x1,T y1,T x2, T y2){return sqrt( (double)( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ) );}
template<typename T> T ANGLE(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template<typename T> LL isLeft(T a,T b,T c) { return (c.x-a.x)*(b.y-a.y)-(b.x-a.x)*(c.y-a.y); }
const long long int MOD=1e9+7;
//struct info{LL x,y;}arr[100005];bool com(info a,info b){return (a.x<b.x) or (a.x==b.x and a.y<b.y);}
LL ar[1002],br[1002];
LL a=0,b=0,c=0,r=0,rr=0,res=0,n,t=0,ks=0,k;
string  s;

struct info
{
    LL m[105][105];
}base;

info mul(info aa,info bb)
{

    info mat;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            mat.m[i][j]=0;
            LL tot=0;
            for(int k=0;k<n;k++)
            {
               tot=(tot+(aa.m[i][k]*bb.m[k][j])%MOD)% MOD;
            }
             mat.m[i][j]=tot;
        }

    }

    return mat;
}

info bigmod(info ee,LL n)
{
     info ans=base;
    k--;
    while(k>0)
    {
        if(k%2==1)
        {
            ans=mul(ans,base);
        }
        base=mul(base,base);
        k/=2;
    }

    return ans;

}

int main()
{
    //Fast;

    cin>>n;cin>>k;

    rep(i,n)  cin>>ar[i];

    rep(i,n)
    {
        rep(j,n)
        {
            LL aa=ar[i]^ar[j];
            int  dd=__builtin_popcount(aa);
            if(dd%3==0)base.m[i][j]=1;
        }
    }

    if(k==1)
    {
        cout<<n;

        return 0;
    }

    info ans=bigmod( base,k-1);

    rep(i,n)
    {
        rep(j,n)
        {
            r+=ans.m[i][j];

          r%=MOD;
        }
    }
    cout<<r;

   return 0;

}


using namespace std;
#include<bits/stdc++.h>
typedef long long   LL;
typedef long long   ll;
typedef   pair<LL,LL>  PII;
typedef   vector< PII > VPII;
typedef   vector<long long>   VI;
typedef   map<string,LL>  MSI;
typedef   map<LL,LL>  MII;
///Print
#define R(n)       scanf("%lld", &n)
#define P(a)  printf("%lld\n",a)
#define NL printf("\n")
#define case(no) printf("Case %lld: ",++no)
#define casenl(no) printf("Case %lld:\n",++no)
///LOOP
#define rep(x,n) for(__typeof(n) x=0;x<(n);x++)
#define reps(i,x) for(int  i=0;i<(x.size());i++)
#define repp(x,n) for(__typeof(n) x=1;x<=(n);x++)
#define FORSTL(x,n) for(__typeof(n.begin()) x=n.begin();x!=n.end();x++)
///Shortcut
#define mem(ar,value) memset(ar,value,sizeof(ar))
#define all(x) x.begin(),x.end()
#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())
#define len(s) s.size()
#define mp make_pair
#define pb push_back
#define FF first
#define SS second
#define LB(a,x) (lower_bound(all(a),x)-a.begin()) ///first element in the range [first,last) which does not compare less than val.
#define UB(a,x) (upper_bound(all(a),x)-a.begin()) ///first element in the range [first,last) which compares greater than val.
#define MOD 1e9+7
///Min AND Max
#define MIN3(a,b,c) min(a,min(b,c))
#define MAX3(a,b,c) max(a,max(b,c))
#define EPS (1e-9)
#define PI acos(-1.0)
#define isEq(a,b) (fabs((a)-(b))<eps)
#define Fast ios_base::sync_with_stdio(false); cin.tie(false);
///DEBUG
#define D(x) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<endl;
#define DD(x,y) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<" | "#y" = "<<y<<endl;
#define DDD(x,y,z) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<" | "#y" = "<<y<<" | "#z" ="<<z<<endl;
///Gcd and Lcm
template<class T>T gcd(T a,T b){return b == 0 ? a : gcd(b, a % b);}
template<typename T>T lcm(T a, T b) {return a / gcd(a,b) * b;}
///Bigmod && Pow
template<class T>T my_pow(T n,T p){if(p==0)return 1;T x=my_pow(n,p/2);x=(x*x);if(p&1)x=(x*n);return x;} ///n to the power p
template<class T>T big_mod(T n,T p,T m){if(p==0)return (T)1;T x=big_mod(n,p/2,m);x=(x*x)%m;if(p&1)x=(x*n)%m;return x;}
///string to int
template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}///
string itos(LL n){string s;while(n){s+=(n%10+48);n/=10;}reverse(all(s));return s;}
LL stoi(string s){LL n=0;rep(i,len(s))n=n*10+(s[i]-48);return n;}
/// geometry
double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}
template<typename T> T DIS(T x1,T y1,T x2, T y2){return sqrt( (double)( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ) );}
template<typename T> T ANGLE(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template<typename T> LL isLeft(T a,T b,T c) { return (c.x-a.x)*(b.y-a.y)-(b.x-a.x)*(c.y-a.y); }
//struct info{LL x,y;}arr[100005];bool com(info a,info b){return (a.x<b.x) or (a.x==b.x and a.y<b.y);}
LL ar[102],br[102];
LL a=0,b=0,c=0,r=0,rr=0,res=0,n,m,t=0,ks=0,k;
string  s;

struct info
{
    LL m[105][105];
}base,kk,dd;

info mul(info aa,info bb)
{

    info mat;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            mat.m[i][j]=0;

            for(int k=0;k<n;k++)
            {
                mat.m[i][j]+=(aa.m[i][k]*bb.m[k][j]*1LL)%1000000007LL;

                mat.m[i][j]%=1000000007LL;
            }
        }
    }

    return mat;
}

int main()
{
    //Fast;

    cin>>n;cin>>k;

    if(k==1)
    {
        cout<<n;

        return 0;
    }

    rep(i,n)  cin>>ar[i];

    rep(i,n)
    {
        rep(j,n)
        {
            LL aa=ar[i]^ar[j];

            if(__builtin_popcount(aa)%3==0)base.m[i][j]=1;
            else  base.m[i][j]=0;
        }
    }

    k--;
    info ans=base;
    k--;

    while(k>0)
    {
        if(k%2==1)
        {

            ans=mul(ans,base);

        }

        base=mul(base,base);
        k/=2;
    }

    rep(i,n)
    {
        rep(j,n)
        {
            r+=ans.m[i][j];

          r%=1000000007LL;
        }
    }
    cout<<r;

   return 0;

}


using namespace std;
#include<bits/stdc++.h>
typedef long long   LL;
typedef long long   ll;
typedef   pair<LL,LL>  PII;
typedef   vector< PII > VPII;
typedef   vector<long long>   VI;
typedef   map<string,LL>  MSI;
typedef   map<LL,LL>  MII;
///Print
#define R(n)       scanf("%lld", &n)
#define P(a)  printf("%lld\n",a)
#define NL printf("\n")
#define case(no) printf("Case %lld: ",++no)
#define casenl(no) printf("Case %lld:\n",++no)
///LOOP
#define rep(x,n) for(__typeof(n) x=0;x<(n);x++)
#define reps(i,x) for(int  i=0;i<(x.size());i++)
#define repp(x,n) for(__typeof(n) x=1;x<=(n);x++)
#define FORSTL(x,n) for(__typeof(n.begin()) x=n.begin();x!=n.end();x++)
///Shortcut
#define mem(ar,value) memset(ar,value,sizeof(ar))
#define all(x) x.begin(),x.end()
#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())
#define len(s) s.size()
#define mp make_pair
#define pb push_back
#define FF first
#define SS second
#define LB(a,x) (lower_bound(all(a),x)-a.begin()) ///first element in the range [first,last) which does not compare less than val.
#define UB(a,x) (upper_bound(all(a),x)-a.begin()) ///first element in the range [first,last) which compares greater than val.
///Min AND Max
#define MIN3(a,b,c) min(a,min(b,c))
#define MAX3(a,b,c) max(a,max(b,c))
#define EPS (1e-9)
#define PI acos(-1.0)
#define isEq(a,b) (fabs((a)-(b))<eps)
#define Fast ios_base::sync_with_stdio(false); cin.tie(false);
///DEBUG
#define D(x) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<endl;
#define DD(x,y) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<" | "#y" = "<<y<<endl;
#define DDD(x,y,z) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<" | "#y" = "<<y<<" | "#z" ="<<z<<endl;
///Gcd and Lcm
template<class T>T gcd(T a,T b){return b == 0 ? a : gcd(b, a % b);}
template<typename T>T lcm(T a, T b) {return a / gcd(a,b) * b;}
///Bigmod && Pow
template<class T>T my_pow(T n,T p){if(p==0)return 1;T x=my_pow(n,p/2);x=(x*x);if(p&1)x=(x*n);return x;} ///n to the power p
template<class T>T big_mod(T n,T p,T m){if(p==0)return (T)1;T x=big_mod(n,p/2,m);x=(x*x)%m;if(p&1)x=(x*n)%m;return x;}
///string to int
template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}///
string itos(LL n){string s;while(n){s+=(n%10+48);n/=10;}reverse(all(s));return s;}
LL stoi(string s){LL n=0;rep(i,len(s))n=n*10+(s[i]-48);return n;}
/// geometry
double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}
template<typename T> T DIS(T x1,T y1,T x2, T y2){return sqrt( (double)( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ) );}
template<typename T> T ANGLE(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template<typename T> LL isLeft(T a,T b,T c) { return (c.x-a.x)*(b.y-a.y)-(b.x-a.x)*(c.y-a.y); }
const long long int MOD=1e9+7;
//struct info{LL x,y;}arr[100005];bool com(info a,info b){return (a.x<b.x) or (a.x==b.x and a.y<b.y);}
LL ar[1002],br[1002];
LL a=0,b=0,c=0,r=0,rr=0,res=0,n,t=0,ks=0,k;
string  s;
struct info
{
    LL m[105][105];
}base;
info multi(info aa,info bb)
{

    info mat;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            mat.m[i][j]=0;
            LL tot=0;
            for(int k=0;k<n;k++)
            {
               //tot=(tot+(aa.m[i][k]*bb.m[k][j])%MOD)% MOD;

                tot=(tot+aa.m[i][k]*bb.m[k][j])%MOD;
            }
             mat.m[i][j]=tot;
        }

    }

    return mat;
}

info bigmod(info ee,LL k)
{
     info ans=ee;
    k--;
    while(k>0)
    {
        if(k&1)
        {
            ans=multi(ans,ee);
        }
        ee=multi(ee,ee);
        k/=2;
    }

    return ans;

}

int main()
{
    //Fast;
    cin>>n;cin>>k;
    rep(i,n)  cin>>ar[i];
    rep(i,n)
    {
        rep(j,n)
        {
            LL aa=ar[i]^ar[j];
            int  dd=__builtin_popcountll(aa);
            if(dd%3==0)base.m[i][j]=1;
        }
    }
    if(k==1)
    {
        cout<<n;
        return 0;
    }
    info ans=bigmod( base,k-1);
    rep(i,n)
    {
        rep(j,n)
        {
         r+=ans.m[i][j];
          r%=MOD;
        }
    }
    cout<<r;

   return 0;

}


using namespace std;
#include<bits/stdc++.h>
typedef long long   LL;
typedef long long   ll;
typedef   pair<LL,LL>  PII;
typedef   vector< PII > VPII;
typedef   vector<long long>   VI;
typedef   map<string,LL>  MSI;
typedef   map<LL,LL>  MII;
///Print
#define R(n)       scanf("%lld", &n)
#define P(a)  printf("%lld\n",a)
#define NL printf("\n")
#define case(no) printf("Case %lld: ",++no)
#define casenl(no) printf("Case %lld:\n",++no)
///LOOP
#define rep(x,n) for(__typeof(n) x=0;x<(n);x++)
#define reps(i,x) for(int  i=0;i<(x.size());i++)
#define repp(x,n) for(__typeof(n) x=1;x<=(n);x++)
#define FORSTL(x,n) for(__typeof(n.begin()) x=n.begin();x!=n.end();x++)
///Shortcut
#define mem(ar,value) memset(ar,value,sizeof(ar))
#define all(x) x.begin(),x.end()
#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())
#define len(s) s.size()
#define mp make_pair
#define pb push_back
#define FF first
#define SS second
#define LB(a,x) (lower_bound(all(a),x)-a.begin()) ///first element in the range [first,last) which does not compare less than val.
#define UB(a,x) (upper_bound(all(a),x)-a.begin()) ///first element in the range [first,last) which compares greater than val.
#define MOD 1e9+7
///Min AND Max
#define MIN3(a,b,c) min(a,min(b,c))
#define MAX3(a,b,c) max(a,max(b,c))
#define EPS (1e-9)
#define PI acos(-1.0)
#define isEq(a,b) (fabs((a)-(b))<eps)
#define Fast ios_base::sync_with_stdio(false); cin.tie(false);
///DEBUG
#define D(x) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<endl;
#define DD(x,y) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<" | "#y" = "<<y<<endl;
#define DDD(x,y,z) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<" | "#y" = "<<y<<" | "#z" ="<<z<<endl;
///Gcd and Lcm
template<class T>T gcd(T a,T b){return b == 0 ? a : gcd(b, a % b);}
template<typename T>T lcm(T a, T b) {return a / gcd(a,b) * b;}
///Bigmod && Pow
template<class T>T my_pow(T n,T p){if(p==0)return 1;T x=my_pow(n,p/2);x=(x*x);if(p&1)x=(x*n);return x;} ///n to the power p
template<class T>T big_mod(T n,T p,T m){if(p==0)return (T)1;T x=big_mod(n,p/2,m);x=(x*x)%m;if(p&1)x=(x*n)%m;return x;}
///string to int
template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}///
string itos(LL n){string s;while(n){s+=(n%10+48);n/=10;}reverse(all(s));return s;}
LL stoi(string s){LL n=0;rep(i,len(s))n=n*10+(s[i]-48);return n;}
/// geometry
double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}
template<typename T> T DIS(T x1,T y1,T x2, T y2){return sqrt( (double)( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ) );}
template<typename T> T ANGLE(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template<typename T> LL isLeft(T a,T b,T c) { return (c.x-a.x)*(b.y-a.y)-(b.x-a.x)*(c.y-a.y); }
//struct info{LL x,y;}arr[100005];bool com(info a,info b){return (a.x<b.x) or (a.x==b.x and a.y<b.y);}
LL ar[60],br[60];
LL a=0,b=0,c=0,r=0,rr=0,res=0,n,m,t=0,ks=0,k;
string  s;

struct info
{
    LL m[105][105];
}base,kk,dd;

info mul(info aa,info bb)
{

    info mat;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            mat.m[i][j]=0;

            for(int k=0;k<n;k++)
            {
                mat.m[i][j]+=(aa.m[i][k]*bb.m[k][j])%1000000007;

                mat.m[i][j]%=1000000007;
            }
        }
    }

    return mat;
}

int main()
{
    //Fast;

    cin>>n;cin>>k;

    if(k==1)
    {
        cout<<n;

        return 0;
    }

    rep(i,n)  cin>>ar[i];

    rep(i,n)
    {
        rep(j,n)
        {
            LL aa=ar[i]^ar[j];

            if(__builtin_popcountll(aa)%3==0)base.m[i][j]=1;
            else  base.m[i][j]=0;
        }
    }

    k--;
    info ans=base;
    k--;

    while(k>0)
    {
        if(k%2==1)
        {

            ans=mul(ans,base);

        }

        base=mul(base,base);
        k/=2;
    }

    rep(i,n)
    {
        rep(j,n)
        {
            r+=ans.m[i][j];

          r%=1000000007;
        }
    }
    cout<<r;

   return 0;

}


using namespace std;
#include<bits/stdc++.h>
typedef long long   LL;
typedef long long   ll;
typedef   pair<LL,LL>  PII;
typedef   vector< PII > VPII;
typedef   vector<long long>   VI;
typedef   map<string,LL>  MSI;
typedef   map<LL,LL>  MII;
///Print
#define R(n)       scanf("%lld", &n)
#define P(a)  printf("%lld\n",a)
#define NL printf("\n")
#define case(no) printf("Case %lld: ",++no)
#define casenl(no) printf("Case %lld:\n",++no)
///LOOP
#define rep(x,n) for(__typeof(n) x=0;x<(n);x++)
#define reps(i,x) for(int  i=0;i<(x.size());i++)
#define repp(x,n) for(__typeof(n) x=1;x<=(n);x++)
#define FORSTL(x,n) for(__typeof(n.begin()) x=n.begin();x!=n.end();x++)
///Shortcut
#define mem(ar,value) memset(ar,value,sizeof(ar))
#define all(x) x.begin(),x.end()
#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())
#define len(s) s.size()
#define mp make_pair
#define pb push_back
#define FF first
#define SS second
#define LB(a,x) (lower_bound(all(a),x)-a.begin()) ///first element in the range [first,last) which does not compare less than val.
#define UB(a,x) (upper_bound(all(a),x)-a.begin()) ///first element in the range [first,last) which compares greater than val.
#define MOD 1e9+7
///Min AND Max
#define MIN3(a,b,c) min(a,min(b,c))
#define MAX3(a,b,c) max(a,max(b,c))
#define EPS (1e-9)
#define PI acos(-1.0)
#define isEq(a,b) (fabs((a)-(b))<eps)
#define Fast ios_base::sync_with_stdio(false); cin.tie(false);
///DEBUG
#define D(x) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<endl;
#define DD(x,y) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<" | "#y" = "<<y<<endl;
#define DDD(x,y,z) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<" | "#y" = "<<y<<" | "#z" ="<<z<<endl;
///Gcd and Lcm
template<class T>T gcd(T a,T b){return b == 0 ? a : gcd(b, a % b);}
template<typename T>T lcm(T a, T b) {return a / gcd(a,b) * b;}
///Bigmod && Pow
template<class T>T my_pow(T n,T p){if(p==0)return 1;T x=my_pow(n,p/2);x=(x*x);if(p&1)x=(x*n);return x;} ///n to the power p
template<class T>T big_mod(T n,T p,T m){if(p==0)return (T)1;T x=big_mod(n,p/2,m);x=(x*x)%m;if(p&1)x=(x*n)%m;return x;}
///string to int
template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}///
string itos(LL n){string s;while(n){s+=(n%10+48);n/=10;}reverse(all(s));return s;}
LL stoi(string s){LL n=0;rep(i,len(s))n=n*10+(s[i]-48);return n;}
/// geometry
double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}
template<typename T> T DIS(T x1,T y1,T x2, T y2){return sqrt( (double)( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ) );}
template<typename T> T ANGLE(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template<typename T> LL isLeft(T a,T b,T c) { return (c.x-a.x)*(b.y-a.y)-(b.x-a.x)*(c.y-a.y); }
//struct info{LL x,y;}arr[100005];bool com(info a,info b){return (a.x<b.x) or (a.x==b.x and a.y<b.y);}
LL ar[102],br[102];
LL a=0,b=0,c=0,r=0,rr=0,res=0,n,m,t=0,ks=0,k;
string  s;

struct info
{
    LL m[105][105];
}base,kk,dd;

info mul(info aa,info bb)
{

    info mat;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            mat.m[i][j]=0;

            for(int k=0;k<n;k++)
            {
                mat.m[i][j]+=(aa.m[i][k]*bb.m[k][j]*1LL)%1000000007LL;

                mat.m[i][j]%=1000000007LL;
            }
        }
    }

    return mat;
}

int main()
{
    //Fast;

    cin>>n;cin>>k;

    if(k==1)
    {
        cout<<n;

        return 0;
    }

    rep(i,n)  cin>>ar[i];

    rep(i,n)
    {
        rep(j,n)
        {
            LL aa=ar[i]^ar[j];

            if(__builtin_popcount(aa)%3==0)base.m[i][j]=1;
            else  base.m[i][j]=0;
        }
    }

    k--;
    info ans=base;
    k--;

    while(k>0)
    {
        if(k%2==1)
        {

            ans=mul(ans,base);

        }

        base=mul(base,base);
        k/=2;
    }

    rep(i,n)
    {
        rep(j,n)
        {
            r+=ans.m[i][j];

          r%=1000000007;
        }
    }
    cout<<r;

   return 0;

}


using namespace std;
#include<bits/stdc++.h>
typedef long long   LL;
typedef long long   ll;
typedef   pair<LL,LL>  PII;
typedef   vector< PII > VPII;
typedef   vector<long long>   VI;
typedef   map<string,LL>  MSI;
typedef   map<LL,LL>  MII;
///Print
#define R(n)       scanf("%lld", &n)
#define P(a)  printf("%lld\n",a)
#define NL printf("\n")
#define case(no) printf("Case %lld: ",++no)
#define casenl(no) printf("Case %lld:\n",++no)
///LOOP
#define rep(x,n) for(__typeof(n) x=0;x<(n);x++)
#define reps(i,x) for(int  i=0;i<(x.size());i++)
#define repp(x,n) for(__typeof(n) x=1;x<=(n);x++)
#define FORSTL(x,n) for(__typeof(n.begin()) x=n.begin();x!=n.end();x++)
///Shortcut
#define mem(ar,value) memset(ar,value,sizeof(ar))
#define all(x) x.begin(),x.end()
#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())
#define len(s) s.size()
#define mp make_pair
#define pb push_back
#define FF first
#define SS second
#define LB(a,x) (lower_bound(all(a),x)-a.begin()) ///first element in the range [first,last) which does not compare less than val.
#define UB(a,x) (upper_bound(all(a),x)-a.begin()) ///first element in the range [first,last) which compares greater than val.
///Min AND Max
#define MIN3(a,b,c) min(a,min(b,c))
#define MAX3(a,b,c) max(a,max(b,c))
#define EPS (1e-9)
#define PI acos(-1.0)
#define isEq(a,b) (fabs((a)-(b))<eps)
#define Fast ios_base::sync_with_stdio(false); cin.tie(false);
///DEBUG
#define D(x) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<endl;
#define DD(x,y) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<" | "#y" = "<<y<<endl;
#define DDD(x,y,z) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<" | "#y" = "<<y<<" | "#z" ="<<z<<endl;
///Gcd and Lcm
template<class T>T gcd(T a,T b){return b == 0 ? a : gcd(b, a % b);}
template<typename T>T lcm(T a, T b) {return a / gcd(a,b) * b;}
///Bigmod && Pow
template<class T>T my_pow(T n,T p){if(p==0)return 1;T x=my_pow(n,p/2);x=(x*x);if(p&1)x=(x*n);return x;} ///n to the power p
template<class T>T big_mod(T n,T p,T m){if(p==0)return (T)1;T x=big_mod(n,p/2,m);x=(x*x)%m;if(p&1)x=(x*n)%m;return x;}
///string to int
template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}///
string itos(LL n){string s;while(n){s+=(n%10+48);n/=10;}reverse(all(s));return s;}
LL stoi(string s){LL n=0;rep(i,len(s))n=n*10+(s[i]-48);return n;}
/// geometry
double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}
template<typename T> T DIS(T x1,T y1,T x2, T y2){return sqrt( (double)( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ) );}
template<typename T> T ANGLE(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template<typename T> LL isLeft(T a,T b,T c) { return (c.x-a.x)*(b.y-a.y)-(b.x-a.x)*(c.y-a.y); }
const long long int MOD=1e9+7;
//struct info{LL x,y;}arr[100005];bool com(info a,info b){return (a.x<b.x) or (a.x==b.x and a.y<b.y);}
LL ar[1002],br[1002];
LL a=0,b=0,c=0,r=0,rr=0,res=0,n,t=0,ks=0,k;
string  s;

struct info
{
    LL m[105][105];
}base;

info mul(info aa,info bb)
{

    info mat;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            mat.m[i][j]=0;
            LL tot=0;
            for(int k=0;k<n;k++)
            {
               tot=(tot+(aa.m[i][k]*bb.m[k][j])%MOD)% MOD;
            }
             mat.m[i][j]=tot;
        }

    }

    return mat;
}

info bigmod(info ee,LL k)
{
     info ans=ee;
    k--;
    while(k>0)
    {
        if(k%2==1)
        {
            ans=mul(ans,ee);
        }
        ee=mul(ee,ee);
        k/=2;
    }

    return ans;

}

int main()
{
    //Fast;

    cin>>n;cin>>k;

    rep(i,n)  cin>>ar[i];

    rep(i,n)
    {
        rep(j,n)
        {
            LL aa=ar[i]^ar[j];
            int  dd=__builtin_popcount(aa);
            if(dd%3==0)base.m[i][j]=1;
        }
    }

    if(k==1)
    {
        cout<<n;

        return 0;
    }

    info ans=bigmod( base,k-1);

    rep(i,n)
    {
        rep(j,n)
        {
            r+=ans.m[i][j];

          r%=MOD;
        }
    }
    cout<<r;

   return 0;

}


using namespace std;
#include<bits/stdc++.h>
typedef long long   LL;
typedef long long   ll;
typedef   pair<LL,LL>  PII;
typedef   vector< PII > VPII;
typedef   vector<long long>   VI;
typedef   map<string,LL>  MSI;
typedef   map<LL,LL>  MII;
///Print
#define R(n)       scanf("%lld", &n)
#define P(a)  printf("%lld\n",a)
#define NL printf("\n")
#define case(no) printf("Case %lld: ",++no)
#define casenl(no) printf("Case %lld:\n",++no)
///LOOP
#define rep(x,n) for(__typeof(n) x=0;x<(n);x++)
#define reps(i,x) for(int  i=0;i<(x.size());i++)
#define repp(x,n) for(__typeof(n) x=1;x<=(n);x++)
#define FORSTL(x,n) for(__typeof(n.begin()) x=n.begin();x!=n.end();x++)
///Shortcut
#define mem(ar,value) memset(ar,value,sizeof(ar))
#define all(x) x.begin(),x.end()
#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())
#define len(s) s.size()
#define mp make_pair
#define pb push_back
#define FF first
#define SS second
#define LB(a,x) (lower_bound(all(a),x)-a.begin()) ///first element in the range [first,last) which does not compare less than val.
#define UB(a,x) (upper_bound(all(a),x)-a.begin()) ///first element in the range [first,last) which compares greater than val.
#define MOD 1e9+7
///Min AND Max
#define MIN3(a,b,c) min(a,min(b,c))
#define MAX3(a,b,c) max(a,max(b,c))
#define EPS (1e-9)
#define PI acos(-1.0)
#define isEq(a,b) (fabs((a)-(b))<eps)
#define Fast ios_base::sync_with_stdio(false); cin.tie(false);
///DEBUG
#define D(x) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<endl;
#define DD(x,y) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<" | "#y" = "<<y<<endl;
#define DDD(x,y,z) cerr<<__FUNCTION__<<":"<<__LINE__<<": "#x" = "<<x<<" | "#y" = "<<y<<" | "#z" ="<<z<<endl;
///Gcd and Lcm
template<class T>T gcd(T a,T b){return b == 0 ? a : gcd(b, a % b);}
template<typename T>T lcm(T a, T b) {return a / gcd(a,b) * b;}
///Bigmod && Pow
template<class T>T my_pow(T n,T p){if(p==0)return 1;T x=my_pow(n,p/2);x=(x*x);if(p&1)x=(x*n);return x;} ///n to the power p
template<class T>T big_mod(T n,T p,T m){if(p==0)return (T)1;T x=big_mod(n,p/2,m);x=(x*x)%m;if(p&1)x=(x*n)%m;return x;}
///string to int
template <class T> T extract(string s, T ret) {stringstream ss(s); ss >> ret; return ret;}///
string itos(LL n){string s;while(n){s+=(n%10+48);n/=10;}reverse(all(s));return s;}
LL stoi(string s){LL n=0;rep(i,len(s))n=n*10+(s[i]-48);return n;}
/// geometry
double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}
template<typename T> T DIS(T x1,T y1,T x2, T y2){return sqrt( (double)( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ) );}
template<typename T> T ANGLE(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template<typename T> LL isLeft(T a,T b,T c) { return (c.x-a.x)*(b.y-a.y)-(b.x-a.x)*(c.y-a.y); }
//struct info{LL x,y;}arr[100005];bool com(info a,info b){return (a.x<b.x) or (a.x==b.x and a.y<b.y);}
LL ar[60],br[60];
LL a=0,b=0,c=0,r=0,rr=0,res=0,n,m,t=0,ks=0,k;
string  s;

struct info
{
    LL m[105][105];
}base,kk,dd;

info mul(info aa,info bb)
{

    info mat;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            mat.m[i][j]=0;

            for(int k=0;k<n;k++)
            {
                mat.m[i][j]+=(aa.m[i][k]*bb.m[k][j])%1000000007;

                mat.m[i][j]%=1000000007;
            }
        }
    }

    return mat;
}

int main()
{
    //Fast;

    cin>>n;cin>>k;

    if(k==1)
    {
        cout<<n;

        return 0;
    }

    rep(i,n)  cin>>ar[i];

    rep(i,n)
    {
        rep(j,n)
        {
            LL aa=ar[i]^ar[j];

            if(__builtin_popcount(aa)%3==0)base.m[i][j]=1;
            else  base.m[i][j]=0;
        }
    }

    k--;
    info ans=base;
    k--;

    while(k>0)
    {
        if(k%2==1)
        {

            ans=mul(ans,base);

        }

        base=mul(base,base);
        k/=2;
    }

    rep(i,n)
    {
        rep(j,n)
        {
            r+=ans.m[i][j];

          r%=1000000007;
        }
    }
    cout<<r;

   return 0;

}


#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef vector<vector<long long> > matrix;
long long mod = 1000000007LL;
long long n,k;
long long add(long long x,long long y){
    return (x+y)%mod;
}
long long mul(long long x,long long y){
    return (x*y)%mod;
}
matrix mul_mat(matrix a,matrix b){
    matrix re;
    re.assign(n,vector<long long>(n,0LL));
    for(long long i=0;i<n;i++){
        for(long long j=0;j<n;j++){
            for(long long k=0;k<n;k++){
                re[i][j]=add(re[i][j],mul(a[i][k],b[k][j]));
            }
        }
    }
    return re;
}
vector<long long> a;
matrix mat;
matrix pow_mat(matrix a,long long x){
    if(x==0LL){
        matrix re;
        re.assign(n,vector<long long>(n,0LL));
        for(long long i=0;i<n;i++){
            re[i][i]=1LL;
        }
        return re;
    }
    matrix ans = pow_mat(a,x/2);
    ans=mul_mat(ans,ans);
    if(x%2) ans = mul_mat(ans,a);
    return ans;
}
int main(){
    cin>>n>>k;
    for(long long i=0;i<n;i++){
        long long x;
        scanf("%I64d",&x);
        a.push_back(x);
    }
    mat.assign(n,vector<long long>(n,0LL));
    for(long long i=0;i<n;i++){
        for(long long j=0;j<n;j++){
            if(((a[i]^a[j])%3LL)==0){
                mat[i][j]=1LL;
            }
        }
    }
    mat=pow_mat(mat,k-1);
    long long ans = 0LL;
    for(long long i=0;i<n;i++){
        for(long long j=0;j<n;j++){
            ans=add(ans,mat[i][j]);
        }
    }

    cout<<ans<<endl;

    return 0;
}


#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef vector<vector<long long> > matrix;
long long mod = 1000000007LL;
long long n,k;
long long add(long long x,long long y){
    return (x+y)%mod;
}
long long mul(long long x,long long y){
    return (x*y)%mod;
}
matrix mul_mat(matrix a,matrix b){
    matrix re;
    re.assign(n,vector<long long>(n,0LL));
    for(long long i=0;i<n;i++){
        for(long long j=0;j<n;j++){
            for(long long k=0;k<n;k++){
                re[i][j]=add(re[i][j],mul(a[i][k],b[k][j]));
            }
        }
    }
    return re;
}
vector<long long> a;
matrix mat;
matrix pow_mat(matrix a,long long x){
    if(x==0LL){
        matrix re;
        re.assign(n,vector<long long>(n,0LL));
        for(long long i=0;i<n;i++){
            re[i][i]=1LL;
        }
        return re;
    }
    matrix ans = pow_mat(a,x/2);
    ans=mul_mat(ans,ans);
    if(x%2) ans = mul_mat(ans,a);
    return ans;
}
int main(){
    cin>>n>>k;
    for(long long i=0;i<n;i++){
        long long x;
        scanf("%I64d",&x);
        a.push_back(x);
    }
    mat.assign(n,vector<long long>(n,0LL));
    for(long long i=0;i<n;i++){
        for(long long j=0;j<n;j++){
            if((a[i]^a[j])%3LL==0){
                mat[i][j]=1LL;
            }
        }
    }
    mat=pow_mat(mat,k-1);
    long long ans = 0LL;
    for(long long j=0;j<n;j++){
        for(long long k=0;k<n;k++){
            ans=add(ans,mul(1LL,mat[k][j]));
        }
    }
    cout<<ans<<endl;

    return 0;
}


#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef vector<vector<long long> > matrix;
long long mod = 1000000007LL;
long long n,k;
long long add(long long x,long long y){
    return (x+y)%mod;
}
long long mul(long long x,long long y){
    return (x*y)%mod;
}
matrix mul_mat(matrix a,matrix b){
    matrix re;
    re.assign(n,vector<long long>(n,0LL));
    for(long long i=0;i<n;i++){
        for(long long j=0;j<n;j++){
            for(long long k=0;k<n;k++){
                re[i][j]=add(re[i][j],mul(a[i][k],b[k][j]));
            }
        }
    }
    return re;
}
vector<long long> a;
matrix mat;
matrix pow_mat(matrix a,long long x){
    if(x==0LL){
        matrix re;
        re.assign(n,vector<long long>(n,0LL));
        for(long long i=0;i<n;i++){
            re[i][i]=1LL;
        }
        return re;
    }
    matrix ans = pow_mat(a,x/2);
    ans=mul_mat(ans,ans);
    if(x%2) ans = mul_mat(ans,a);
    return ans;
}
int main(){
    cin>>n>>k;
    for(long long i=0;i<n;i++){
        long long x;
        scanf("%I64d",&x);
        a.push_back(x);
    }
    mat.assign(n,vector<long long>(n,0LL));
    for(long long i=0;i<n;i++){
        for(long long j=0;j<n;j++){
            long long temp = a[i]^a[j];
            int cnt=0;
            for(long long k=0;k<63;k++){
                if(((1LL<<k)&temp)!=0LL) cnt++;
            }
            if(cnt%3==0){
                mat[i][j]=1LL;
            }
        }
    }
    mat=pow_mat(mat,k-1);
    long long ans = 0LL;
    for(long long i=0;i<n;i++){
        for(long long j=0;j<n;j++){
            ans=add(ans,mat[i][j]);
        }
    }

    cout<<ans<<endl;

    return 0;
}


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

typedef long long ll;
const int mod = 1e9 + 7;

int N; ll K;
ll A[105];
int C[105][105];

int f[105][105][105];
int c[105][105][105];

int solve(ll len, int dep, int l, int r) {
	if (len == 1) return l == r;
	if (c[dep][l][r]) return f[dep][l][r];
	c[dep][l][r] = 1;
	if (len & 1) {
		for (int k = 1; k <= N; ++k) f[dep][l][r] = (f[dep][l][r] + solve(len / 2 + 1, dep + 1, l, k) * 1LL * solve(len / 2 + 1, dep + 1, k, r)) % mod;
	} else {
		for (int k = 1; k <= N; ++k) f[dep][l][r] = (f[dep][l][r] + solve(len - 1, dep + 1, l, k) * C[k][r]) % mod;
	}
	return f[dep][l][r];
}

int main() {
	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) C[i][j] = (__builtin_popcountll(A[i] ^ A[j]) % 3 == 0);
	int ans = 0;
	for (int i = 1; i <= N; ++i) for (int j = 1; j <= N; ++j) ans = (ans + solve(K, 0, i, j)) % mod;
	cout << ans << endl;
}


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

#define N 101

typedef long long LL;

bool ok(LL x) {
	int rlt = 0;
	while (x) {
		if (x & 1) rlt ++;
		x >>= 1;
	}
	return rlt % 3 == 0;
}

int n;
const int mod = 1e9 + 7;
LL k, x[N];
LL a[N][N], b[N][N], rlt[N][N];

void mat_pow(LL m) {
	for (int i = 1; i <= n; i ++) {
		for (int j = 1; j <= n; j ++) rlt[i][j] = (i == j);
	}
	while (m) {
		if (m & 1) {
			for (int i = 1; i <= n; i ++) {
				for (int j = 1; j <= n; j ++) {
					b[i][j] = 0;
					for (int k = 1; k <= n; k ++) b[i][j] = (b[i][j] + rlt[i][k] * a[k][j]) % mod;
				}
			}
            for (int i = 1; i <= n; i ++) {
				for (int j = 1; j <= n; j ++) rlt[i][j] = b[i][j];
            }
		}
		for (int i = 1; i <= n; i ++) {
			for (int j = 1; j <= n; j ++) {
				b[i][j] = 0;
				for (int k = 1; k <= n; k ++) {
					b[i][j] = (b[i][j] + a[i][j] * a[i][j]) % mod;
				}
			}
		}
		for (int i = 1; i <= n; i ++) {
			for (int j = 1; j <= n; j ++) a[i][j] = b[i][j];
		}
		m >>= 1;
	}
}

int main() {
//	freopen("e.in", "r", stdin);
	cin >> n >> k;
	for (int i = 1; i <= n; i ++) cin >> x[i];
	for (int i = 1; i <= n; i ++) {
		for (int j = 1; j <= n; j ++) if (ok(x[i] ^ x[j])) a[i][j] = 1;
	}
	mat_pow(k - 1);
	LL ans = 0;
	for (int i = 1; i <= n; i ++) {
		for (int j = 1; j <= n; j ++) ans = (ans + rlt[i][j]) % mod;
	}
	cout << ans << endl;
	return 0;
}


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

#define ll long long

void solve() {
	ll n; cin >> n;
	ll ar[n];
	for (ll i = 0; i < n; i++)
		cin >> ar[i];
	ll q, w, h, mxHeight = 0; cin >> q;
	for (ll _n = 0; _n < q; _n++) {
		cin >> w >> h;
		mxHeight = max(ar[w-1], mxHeight);
		cout << mxHeight << "\n";
		mxHeight += h;
	}
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll T = 1;
	while (T--)
		solve();
	return 0;
}


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

#define ll long long

void solve() {
	ll n; cin >> n;
	ll ar[n];
	for (ll i = 0; i < n; i++)
		cin >> ar[i];
	ll q; cin >> q;
	for (ll _n = 0; _n < q; _n++) {
		ll w, h; cin >> w >> h;
		ll mxHeight = ar[0];
		for (int i = 0; i < w; i++)
			mxHeight = max(ar[i], mxHeight);
		cout << mxHeight << "\n";
		for (ll f = 0; f < w; f++)
			ar[f] = mxHeight + h;
	}
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll T = 1;
	while (T--)
		solve();
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int stair[100100];
vector<long long> seg;
vector<long long> lazy;

void init(int n)
{
    int le = (int)(2*pow(2.0,floor((log((double)n)/log(2.0))+1)));
    seg.resize(le,0);
    lazy.resize(le,0);
}

void build(int node,int b,int e)
{
    if(b==e)
    {
        seg[node]=stair[b];
    }else
    {
        int mid = (b+e)/2;
        build(2*node,b,mid);
        build(2*node+1,mid+1,e);
        seg[node] = seg[2*node+1];
    }
}

long long query(int node,int b,int e,int l,int r)
{
    if(lazy[node]!=0)
    {
        seg[node]=lazy[node];
        if(b!=e)
        {
            lazy[2*node]=lazy[2*node+1]=lazy[node];
        }
        lazy[node]=0;
    }
    if(l>e || r<b)return -1;
    if(l<=b && r>=e)return seg[node];

    int mid=(e+b)/2;
    int r1= query(2*node+1,mid+1,e,l,r);
    int r2= query(2*node,b,mid,l,r);
    if(r1==-1)return r2;
    return r1;
}

void update(int node,int b,int e,int l ,int r,long long val)
{
    if(lazy[node])
    {
        seg[node]=lazy[node];
        if(b!=e)
        {
            lazy[2*node]=lazy[2*node+1]=lazy[node];

        }
        lazy[node]=0;
    }
    if(l>e || r<b)return ;
    if(l<=b && r>=e)
    {
        seg[node]=val;
        if(e!=b)
        {
            lazy[2*node]=val;
            lazy[2*node+1]=val;
        }
        return;
    }
    int mid=(e+b)/2;
    update(2*node,b,mid,l,r,val);
    update(2*node+1,mid+1,e,l,r,val);
    seg[node]=seg[2*node+1];
}

int main()
{
    int n,m,w,h;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",stair+i);
    init(n);
    build(1,0,n-1);
    scanf("%d",&m);
    while(m--)
    {
        scanf("%d%d",&w,&h);
        long long ans=query(1,0,n-1,0,w-1);
        update(1,0,n-1,0,w-1,h+ans);
        printf("%d\n",ans);
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int stair[100100];
vector<long long> seg;
vector<long long> lazy;

void init(int n)
{
    int le = (int)(2*pow(2.0,floor((log((double)n)/log(2.0))+1)));
    seg.resize(le,0);
    lazy.resize(le,0);
}

void build(int node,int b,int e)
{
    if(b==e)
    {
        seg[node]=stair[b];
    }else
    {
        int mid = (b+e)/2;
        build(2*node,b,mid);
        build(2*node+1,mid+1,e);
        seg[node] = seg[2*node+1];
    }
}

long long query(int node,int b,int e,int l,int r)
{
    if(lazy[node]!=0)
    {
        seg[node]=lazy[node];
        if(b!=e)
        {
            lazy[2*node]=lazy[node];
            lazy[2*node+1]=lazy[node];
        }
        lazy[node]=0;
    }
    if(l>e || r<b)return -1;
    if(l<=b && r>=e)return seg[node];

    int mid=(e+b)/2;
    long long r1= query(2*node+1,mid+1,e,l,r);
    long long r2= query(2*node,b,mid,l,r);
    return max(r1,r2);
}

void update(int node,int b,int e,int l ,int r,long long val)
{
    if(lazy[node])
    {
        seg[node]=lazy[node];
        if(b!=e)
        {
            lazy[2*node]=lazy[node];
            lazy[2*node+1]=lazy[node];

        }
        lazy[node]=0;
    }
    if(l>e || r<b)return ;
    if(l<=b && r>=e)
    {
        seg[node]=val;
        if(e!=b)
        {
            lazy[2*node]=val;
            lazy[2*node+1]=val;
        }
        return;
    }
    int mid=(e+b)/2;
    update(2*node,b,mid,l,r,val);
    update(2*node+1,mid+1,e,l,r,val);
    seg[node]=max(seg[2*node+1],seg[2*node]);
}

int main()
{
    int n,m,w;
    long long h;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",stair+i);
    init(n);
    build(1,0,n-1);
    scanf("%d",&m);
    while(m--)
    {
        scanf("%d%d",&w,&h);
        long long ans=query(1,0,n-1,0,w-1);
        update(1,0,n-1,0,w-1,h+ans);
        cout<<ans<<'\n';
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int stair[100100];
vector<long long> seg;
vector<long long> lazy;

void init(int n)
{
    int le = (int)(2*pow(2.0,floor((log((double)n)/log(2.0))+1)));
    seg.resize(le,0);
    lazy.resize(le,0);
}

void build(int node,int b,int e)
{
    if(b==e)
    {
        seg[node]=stair[b];
    }else
    {
        int mid = (b+e)/2;
        build(2*node,b,mid);
        build(2*node+1,mid+1,e);
        seg[node] = seg[2*node+1];
    }
}

long long query(int node,int b,int e,int l,int r)
{
    if(lazy[node]!=0)
    {
        seg[node]=lazy[node];
        if(b!=e)
        {
            lazy[2*node]=lazy[node];
            lazy[2*node+1]=lazy[node];
        }
        lazy[node]=0;
    }
    if(l>e || r<b)return -1;
    if(l<=b && r>=e)return seg[node];

    int mid=(e+b)/2;
    long long r1= query(2*node+1,mid+1,e,l,r);
    long long r2= query(2*node,b,mid,l,r);
    return max(r1,r2);
}

void update(int node,int b,int e,int l ,int r,long long val)
{
    if(lazy[node])
    {
        seg[node]=lazy[node];
        if(b!=e)
        {
            lazy[2*node]=lazy[node];
            lazy[2*node+1]=lazy[node];

        }
        lazy[node]=0;
    }
    if(l>e || r<b)return ;
    if(l<=b && r>=e)
    {
        seg[node]=val;
        if(e!=b)
        {
            lazy[2*node]=val;
            lazy[2*node+1]=val;
        }
        return;
    }
    int mid=(e+b)/2;
    update(2*node,b,mid,l,r,val);
    update(2*node+1,mid+1,e,l,r,val);
    seg[node]=max(seg[2*node+1],seg[2*node]);
}

int main()
{
    std::ios::sync_with_stdio(false);

    int n,m,w;
    long long h;
    cin>>n;
    for(int i=0;i<n;i++)cin>>stair[i];
    init(n);
    build(1,0,n-1);
    cin>>m;
    while(m--)
    {
        cin>>w>>h;
        long long ans=query(1,0,n-1,0,w-1);
        update(1,0,n-1,0,w-1,h+ans);
        cout<<ans<<'\n';
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int stair[100100];
vector<long long> seg;
vector<long long> lazy;

void init(int n)
{
    int le = (int)(2*pow(2.0,floor((log((double)n)/log(2.0))+1)));
    seg.resize(le,0);
    lazy.resize(le,0);
}

void build(int node,int b,int e)
{
    if(b==e)
    {
        seg[node]=stair[b];
    }else
    {
        int mid = (b+e)/2;
        build(2*node,b,mid);
        build(2*node+1,mid+1,e);
        seg[node] = seg[2*node+1];
    }
}

long long query(int node,int b,int e,int l,int r)
{
    if(lazy[node]!=0)
    {
        seg[node]=lazy[node];
        if(b!=e)
        {
            lazy[2*node]=lazy[node];
            lazy[2*node+1]=lazy[node];
        }
        lazy[node]=0;
    }
    if(l>e || r<b)return -1;
    if(l<=b && r>=e)return seg[node];

    int mid=(e+b)/2;
    long long r1= query(2*node+1,mid+1,e,l,r);
    long long r2= query(2*node,b,mid,l,r);
    return max(r1,r2);
}

void update(int node,int b,int e,int l ,int r,long long val)
{
    if(lazy[node])
    {
        seg[node]=lazy[node];
        if(b!=e)
        {
            lazy[2*node]=lazy[node];
            lazy[2*node+1]=lazy[node];

        }
        lazy[node]=0;
    }
    if(l>e || r<b)return ;
    if(l<=b && r>=e)
    {
        seg[node]=val;
        if(e!=b)
        {
            lazy[2*node]=val;
            lazy[2*node+1]=val;
        }
        return;
    }
    int mid=(e+b)/2;
    update(2*node,b,mid,l,r,val);
    update(2*node+1,mid+1,e,l,r,val);
    seg[node]=max(seg[2*node+1],seg[2*node]);
}

int main()
{
    int n,m,w,h;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",stair+i);
    init(n);
    build(1,0,n-1);
    scanf("%d",&m);
    while(m--)
    {
        scanf("%d%d",&w,&h);
        long long ans=query(1,0,n-1,0,w-1);
        update(1,0,n-1,0,w-1,h+ans);
        printf("%d\n",ans);
    }

    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define loop(i,N) for(long long int i=0;i<N;i++)
#define vi vector<int>
#define vs vector<string>
#define vl vector<long long int>
#define vpi vector<pair<int,int>>
#define msi map<string,int>
#define mil map<int,long long>
#define lli long long int
using namespace std ;
void ps(string i){
    cout << i << endl;
}

template <class T>
void pt(T s){
    cout << s << endl;
}

void pi(int i){
    cout << i << endl;
}

template <class T>
void pv(vector<T> v){
    loop(i,v.size()){
        pt<T>(v[i]);
    }
}

/*********************************reused****************************/
int n,m;
const int N = 1e5+9;
lli a[N];
lli maxi[N];

int main()
{
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        maxi[i] = a[i];
    }
    cin >> m;
    lli x,y;
    for(lli i=0;i<m;i++){
        cin>>x>>y;
        cout<< maxi[x-1]<<endl;
        if(i<m-1){
            maxi[x-1]+=y;
            for(lli j=0;j<x-1;j++){
                maxi[j] = maxi[x-1];
            }
            for(lli j=x;j<n;j++){
                if(maxi[j]<maxi[x-1]){
                    maxi[j]=maxi[x-1];
                }else{
                    break;
                }
            }
        }

    }
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define loop(i,N) for(int i=0;i<N;i++)
#define vi vector<int>
#define vs vector<string>
#define vl vector<long long int>
#define vpi vector<pair<int,int>>
#define msi map<string,int>
#define mil map<int,long long>
#define lli long long
using namespace std ;
void ps(string i){
    cout << i << endl;
}

template <class T>
void pt(T s){
    cout << s << endl;
}

void pi(int i){
    cout << i << endl;
}

template <class T>
void pv(vector<T> v){
    loop(i,v.size()){
        pt<T>(v[i]);
    }
}

/*********************************reused****************************/
int n,m;
const int N=1e5+7;
vector<lli> a;
map<lli,vector<lli>> maxi;
//pair<lli,lli> b[100009];
int main()
{
    cin>>n;
    lli z;
    loop(i,n){
        cin>>z;
        a.push_back(z);
    }
    loop(i,n){
        vector<lli> v(0);
        v.push_back(a[i]);
        for(int j=i+1;j<n;j++){
            v.push_back(max(v[0],a[j]));
        }
        maxi[i]=v;
    }
    cin >> m;
    lli x,y;
    loop(i,m){
        cin>>x>>y;
        cout<< maxi[0][x-1]<<endl;
        loop(j,x){
            maxi[0][j] = maxi[0][x-1]+y;
        }
    }
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#define loop(i,N) for(long long int i=0;i<N;i++)
#define vi vector<int>
#define vs vector<string>
#define vl vector<long long int>
#define vpi vector<pair<int,int>>
#define msi map<string,int>
#define mil map<int,long long>
#define lli long long int
using namespace std ;
void ps(string i){
    cout << i << endl;
}

template <class T>
void pt(T s){
    cout << s << endl;
}

void pi(int i){
    cout << i << endl;
}

template <class T>
void pv(vector<T> v){
    loop(i,v.size()){
        pt<T>(v[i]);
    }
}

/*********************************reused****************************/
int n,m;
const int N = 1e5+9;
lli maxi[N];

int main()
{
    cin>>n;
    for(int i=0;i<n;i++){
        cin >> maxi[i];
    }
    cin >> m;
    lli x,y;
    for(lli i=0;i<m;i++){
        cin>>x>>y;
        maxi[0] = max(maxi[x-1],maxi[0]);
        cout<<maxi[0] <<endl;
        maxi[0]+=y;
        maxi[x-1] = maxi[0];
    }
    return 0;
}