/// TRIE…….XOR SUM(LESS THAN K)……
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 5000050
bool check(ll n,ll pos)
{
return (bool)(n&(1LL<<pos));
}
ll cumxor[100005];
ll n;
struct Trie
{
ll nextt[maxn][2];
ll traverse[maxn];
ll sz;
Trie()
{
clear();
}
void clear()
{
sz=0;
memset(nextt[0],-1,sizeof(nextt[0]));
memset(traverse,0,sizeof traverse);
}
void add(ll val)
{
ll v=0;
for(ll i = 32; i>= 0; --i)
{
int id = check(val,i);
if(nextt[v][id] == -1)
{
nextt[v][id]=++sz;
memset(nextt[sz],-1,sizeof(nextt[sz]));
}
v=nextt[v][id];
traverse[v]++;
}
}
ll dfs(ll val,ll k)
{
ll v=0;
ll ans=0;
for(ll i=32; i>=0 ; i--)
{
ll id=check(val,i);
ll kid=check(k,i);
if(kid==1){
ans+=traverse[nextt[v][id]];
v=nextt[v][id^1];
}
else
v=nextt[v][id];
if(v==-1)
break;
}
return ans;
}
};
Trie tree;
vector<ll>as;
int main()
{
ll tes,k;
scanf("%lld",&tes);
for(ll cas=1;cas<=tes;cas++)
{
tree.clear();
scanf("%lld%lld",&n,&k);
tree.add(0);
ll ans=0;
for(ll i=1;i<=n;i++)
{
scanf("%lld",&cumxor[i]);
cumxor[i]=cumxor[i-1]^cumxor[i];
ans+=tree.dfs(cumxor[i],k);
tree.add(cumxor[i]);
}
printf("%lld\n",ans);
}
return 0;
}
Ci8vLyBUUklF4oCm4oCmLlhPUiBTVU0oTEVTUyBUSEFOIEsp4oCm4oCmCgojaW5jbHVkZTxiaXRzL3N0ZGMrKy5oPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojZGVmaW5lIGxsIGxvbmcgbG9uZwojZGVmaW5lIG1heG4gNTAwMDA1MAoKYm9vbCBjaGVjayhsbCBuLGxsIHBvcykKewogICAgcmV0dXJuIChib29sKShuJigxTEw8PHBvcykpOwp9CgoKbGwgY3VteG9yWzEwMDAwNV07CmxsIG47CgoKc3RydWN0IFRyaWUKewogICAgbGwgbmV4dHRbbWF4bl1bMl07CiAgICBsbCB0cmF2ZXJzZVttYXhuXTsKICAgIGxsIHN6OwogICAgVHJpZSgpCiAgICB7CiAgICAgICAgY2xlYXIoKTsKICAgIH0KICAgIHZvaWQgY2xlYXIoKQogICAgewogICAgICAgIHN6PTA7CiAgICAgICAgbWVtc2V0KG5leHR0WzBdLC0xLHNpemVvZihuZXh0dFswXSkpOwogICAgICAgIG1lbXNldCh0cmF2ZXJzZSwwLHNpemVvZiB0cmF2ZXJzZSk7CiAgICB9CiAgICB2b2lkIGFkZChsbCB2YWwpCiAgICB7CiAgICAgICAgbGwgdj0wOwogICAgICAgIGZvcihsbCBpID0gMzI7IGk+PSAwOyAtLWkpCiAgICAgICAgewogICAgICAgICAgICBpbnQgaWQgPSBjaGVjayh2YWwsaSk7CiAgICAgICAgICAgIGlmKG5leHR0W3ZdW2lkXSA9PSAtMSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgbmV4dHRbdl1baWRdPSsrc3o7CiAgICAgICAgICAgICAgICBtZW1zZXQobmV4dHRbc3pdLC0xLHNpemVvZihuZXh0dFtzel0pKTsKICAgICAgICAgICAgfQogICAgICAgICAgICB2PW5leHR0W3ZdW2lkXTsKICAgICAgICAgICAgdHJhdmVyc2Vbdl0rKzsKICAgICAgICB9CiAgICB9CiAgICBsbCBkZnMobGwgdmFsLGxsIGspCiAgICB7CiAgICAgICAgbGwgdj0wOwogICAgICAgIGxsIGFucz0wOwogICAgICAgIGZvcihsbCBpPTMyOyBpPj0wIDsgaS0tKQogICAgICAgIHsKICAgICAgICAgICAgbGwgaWQ9Y2hlY2sodmFsLGkpOwogICAgICAgICAgICBsbCBraWQ9Y2hlY2soayxpKTsKICAgICAgICAgICAgaWYoa2lkPT0xKXsKICAgICAgICAgICAgICAgIGFucys9dHJhdmVyc2VbbmV4dHRbdl1baWRdXTsKICAgICAgICAgICAgICAgIHY9bmV4dHRbdl1baWReMV07CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgdj1uZXh0dFt2XVtpZF07CiAgICAgICAgICAgIGlmKHY9PS0xKQogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIHJldHVybiBhbnM7CiAgICB9Cn07CgpUcmllIHRyZWU7CnZlY3RvcjxsbD5hczsKCmludCBtYWluKCkKewogICAgbGwgdGVzLGs7CiAgICBzY2FuZigiJWxsZCIsJnRlcyk7CiAgICBmb3IobGwgY2FzPTE7Y2FzPD10ZXM7Y2FzKyspCiAgICB7CiAgICAgICAgICB0cmVlLmNsZWFyKCk7CiAgICAgICAgICBzY2FuZigiJWxsZCVsbGQiLCZuLCZrKTsKICAgICAgICAgIHRyZWUuYWRkKDApOwogICAgICAgICAgbGwgYW5zPTA7CiAgICAgICAgICBmb3IobGwgaT0xO2k8PW47aSsrKQogICAgICAgICAgewogICAgICAgICAgICAgIHNjYW5mKCIlbGxkIiwmY3VteG9yW2ldKTsKICAgICAgICAgICAgICBjdW14b3JbaV09Y3VteG9yW2ktMV1eY3VteG9yW2ldOwogICAgICAgICAgICAgIGFucys9dHJlZS5kZnMoY3VteG9yW2ldLGspOwogICAgICAgICAgICAgIHRyZWUuYWRkKGN1bXhvcltpXSk7CiAgICAgICAgICB9CiAgICAgICAgICBwcmludGYoIiVsbGRcbiIsYW5zKTsKICAgIH0KICAgIHJldHVybiAwOwp9Cg==