#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
long long t,n,m,k,ccnt,pos=0,sum=0,minn2=INT_MAX,sum2,cnt[65],cnt1=0,cnt2=0,cnt3=0,cnt4=0,cnt5=0,cnt6=0,cnt7=0,a[2000005],x1,y7,x2,y2,x3,y3,aaa,bbb;
long long vis[1000005],b[1000005],c[1000005],c4[1000005],kk[1000005],x,y,z,d=0,l2,r2;
long long pos1=0,pos2=0,tem,tem2,l,r,ans=0,ans2,mod=998244353,tw[100005],th[100005],dd,ee,out[1000005],te[100005],dp[1000005],dp2[1000005],dp3[1000005];
long long minn=LONG_LONG_MAX,maxx=-LONG_LONG_MAX;
int ok[1000005],gr[1000005],ced[1000005],ng[1000005],w[1000005];
string s1,s2,s;
//char cc[2005][2005],ch;
//pair<int,int> p[2000005];
vector<int> v[1000005];
int gsize[1000005];
long long fpow(long long aa,long long bb)
{
    long long kk1=aa;
    long long kk2=1;
    while(bb>1)
    {
        if(bb%2)
        {
            kk2*=kk1;
            kk2%=mod;
        }
        kk1*=kk1;
        kk1%=mod;
        bb=bb/2;
    }
    return (kk1*kk2)%mod;
}
long long co(long long x,long long y)
{
    long long ans=1;
    long long ans2=1;
    if(x==y||y==0)
    {
        return 1;
    }
    else
    {
        for(int i=x-y+1;i<=x;i++)
        {
            ans=ans*i;
            ans=ans%mod;
        }
        for(int i=1;i<=y;i++)
        {
            ans2=ans2*i;
            ans2=ans2%mod;
        }
        ans2=fpow(ans2,mod-2);
        ans2=(ans2*ans)%mod;
        return ans2;
    }
}
void dfs(int x,int y)
{

    vis[x]=1;
    w[cnt3]=x;
    cnt3++;
    gr[x]=gr[y];
    for(int i=0;i<v[x].size();i++)
    {
        if(vis[v[x][i]]==0)
        {
            dfs(v[x][i],y);
        }
    }
    //vis[x]=0;
}
signed main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    cin>>t;
    while(t--)
    {
        mod=1000000007;
        cin>>n;
        for(int i=0;i<=n;i++)
        {
            a[i]=0;
            b[i]=0;
        }
        for(int i=0;i<62;i++)
        {
            cnt[i]=0;
        }
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            if(a[i]==0)
            {

            }
            else
            {
                for(int j=0;j<60;j++)
                {
                    if(a[i]&(1LL<<j)) cnt[j]++;
                }
            }

        }
        ans=0;
        for(int i=0;i<n;i++)
        {
            ll cur=0;
            for(int j=0;j<60;j++)
            {
                if(a[i]&(1LL<<j)) cur=(cur+(1LL<<j)%mod*n%mod)%mod;
                else cur=(cur+(1LL<<j)%mod*cnt[j]%mod)%mod;
            }
            b[i]=cur;
        }
        for(int i=0;i<n;i++)
        {
            if(a[i]==0)
            {

            }
            else
            {
                for(int j=0;j<60;j++)
                {
                    if(a[i]&(1LL<<j))
                    {
                        ll tmp=(1LL<<j)%mod;
                        tmp=tmp*cnt[j]%mod;
                        tmp=tmp*b[i]%mod;
                        ans=(ans+tmp)%mod;
                    }
                }
            }


        }
        cout<<ans%mod<<'\n';
    }
}
/*
 7 9
1 1
1 2
2 3 4
2 5 6
2 7 8
2 9 1
2 2 3
*/

### Prompt

Your challenge is to write a Cpp solution to the following problem:

Only a few know that Pan and Apollo weren't only battling for the title of the GOAT musician. A few millenniums later, they also challenged each other in math (or rather in fast calculations). The task they got to solve is the following:

Let x_1, x_2, …, x_n be the sequence of n non-negative integers. Find this value: $$$∑_{i=1}^n ∑_{j=1}^n ∑_{k=1}^n (x_i   \&   x_j) ⋅ (x_j   |   x_k)$$$

Here \& denotes the [bitwise and,](https://en.wikipedia.org/wiki/Bitwise_operation#AND) and | denotes the [bitwise or.](https://en.wikipedia.org/wiki/Bitwise_operation#OR)

Pan and Apollo could solve this in a few seconds. Can you do it too? For convenience, find the answer modulo 10^9 + 7.

Input

The first line of the input contains a single integer t (1 ≤ t ≤ 1 000) denoting the number of test cases, then t test cases follow.

The first line of each test case consists of a single integer n (1 ≤ n ≤ 5 ⋅ 10^5), the length of the sequence. The second one contains n non-negative integers x_1, x_2, …, x_n (0 ≤ x_i < 2^{60}), elements of the sequence.

The sum of n over all test cases will not exceed 5 ⋅ 10^5.

Output

Print t lines. The i-th line should contain the answer to the i-th text case.

Example

Input


8
2
1 7
3
1 2 4
4
5 5 5 5
5
6 2 2 1 0
1
0
1
1
6
1 12 123 1234 12345 123456
5
536870912 536870911 1152921504606846975 1152921504606846974 1152921504606846973


Output


128
91
1600
505
0
1
502811676
264880351

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
long long t,n,m,k,ccnt,pos=0,sum=0,minn2=INT_MAX,sum2,cnt[65],cnt1=0,cnt2=0,cnt3=0,cnt4=0,cnt5=0,cnt6=0,cnt7=0,a[2000005],x1,y7,x2,y2,x3,y3,aaa,bbb;
long long vis[1000005],b[1000005],c[1000005],c4[1000005],kk[1000005],x,y,z,d=0,l2,r2;
long long pos1=0,pos2=0,tem,tem2,l,r,ans=0,ans2,mod=998244353,tw[100005],th[100005],dd,ee,out[1000005],te[100005],dp[1000005],dp2[1000005],dp3[1000005];
long long minn=LONG_LONG_MAX,maxx=-LONG_LONG_MAX;
int ok[1000005],gr[1000005],ced[1000005],ng[1000005],w[1000005];
string s1,s2,s;
//char cc[2005][2005],ch;
//pair<int,int> p[2000005];
vector<int> v[1000005];
int gsize[1000005];
long long fpow(long long aa,long long bb)
{
    long long kk1=aa;
    long long kk2=1;
    while(bb>1)
    {
        if(bb%2)
        {
            kk2*=kk1;
            kk2%=mod;
        }
        kk1*=kk1;
        kk1%=mod;
        bb=bb/2;
    }
    return (kk1*kk2)%mod;
}
long long co(long long x,long long y)
{
    long long ans=1;
    long long ans2=1;
    if(x==y||y==0)
    {
        return 1;
    }
    else
    {
        for(int i=x-y+1;i<=x;i++)
        {
            ans=ans*i;
            ans=ans%mod;
        }
        for(int i=1;i<=y;i++)
        {
            ans2=ans2*i;
            ans2=ans2%mod;
        }
        ans2=fpow(ans2,mod-2);
        ans2=(ans2*ans)%mod;
        return ans2;
    }
}
void dfs(int x,int y)
{

    vis[x]=1;
    w[cnt3]=x;
    cnt3++;
    gr[x]=gr[y];
    for(int i=0;i<v[x].size();i++)
    {
        if(vis[v[x][i]]==0)
        {
            dfs(v[x][i],y);
        }
    }
    //vis[x]=0;
}
signed main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    cin>>t;
    while(t--)
    {
        mod=1000000007;
        cin>>n;
        for(int i=0;i<=n;i++)
        {
            a[i]=0;
            b[i]=0;
        }
        for(int i=0;i<62;i++)
        {
            cnt[i]=0;
        }
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            if(a[i]==0)
            {

            }
            else
            {
                for(int j=0;j<60;j++)
                {
                    if(a[i]&(1LL<<j)) cnt[j]++;
                }
            }

        }
        ans=0;
        for(int i=0;i<n;i++)
        {
            ll cur=0;
            for(int j=0;j<60;j++)
            {
                if(a[i]&(1LL<<j)) cur=(cur+(1LL<<j)%mod*n%mod)%mod;
                else cur=(cur+(1LL<<j)%mod*cnt[j]%mod)%mod;
            }
            b[i]=cur;
        }
        for(int i=0;i<n;i++)
        {
            if(a[i]==0)
            {

            }
            else
            {
                for(int j=0;j<60;j++)
                {
                    if(a[i]&(1LL<<j))
                    {
                        ll tmp=(1LL<<j)%mod;
                        tmp=tmp*cnt[j]%mod;
                        tmp=tmp*b[i]%mod;
                        ans=(ans+tmp)%mod;
                    }
                }
            }


        }
        cout<<ans%mod<<'\n';
    }
}
/*
 7 9
1 1
1 2
2 3 4
2 5 6
2 7 8
2 9 1
2 2 3
*/

```