# Approach is right but failed at last 2 test cases - (Problem is of Starter-65 - Binod )

// Code by: Abhishek Ikhar
#include<bits/stdc++.h>
// #include “trie.h”
using namespace std;
#define ll unsigned long long
#define vec vector
#define fo(i,l,h) for(ll i=l;i<h;i++)
#define rfo(i,h,l) for(ll i=h;i>=l;i–)
#define sz(x) ((int)x.size())
// gcd
int gcd(int a,int b){
if(b==0){
return a;
}
return gcd(b,a%b);
}

// form bst
class Node{
public:
int val;
Node* left;
Node* right;
Node(int v){
val = v;
left = NULL;
right=NULL;
}
};
//insert
Node* insert(Node* root,int v){
if(!root){
root = new Node(v);
return root;
}
if(vval){
root->left = insert(root->left,v);
}
else{
root->right = insert(root->right,v);
}
return root;
}
//floor func of bst
int floorInBST(Node* root, int X)
{
int ans =-1;
while(root){
if(X==root->val){
ans = root->val;
return ans;
}
if(X>root->val){
ans = root->val;
root = root->right;
}
else{
root = root->left;
}
}
return ans;
}

void inorder(Node* root){
if(!root){
return ;
}
inorder(root->left);
cout<val<<" “;
inorder(root->right);
}
// coding…
// int getBit(ll n,int i){
// if(n&(1ULL<<i)){
// return 1;
// }
// return 0;
// }
void solve(){
int n,q;
cin>>n>>q;
vector arr(n+1);
arr[0]=0;
for(int i=1;i<=n;i++){
cin>>arr[i];
}
vector<vector> cumBit(n+1,vector(60,0));
for(int i=1;i<=n;i++){
for(int j=0;j<60;j++){
cumBit[i][j]=(arr[i]%(2ULL));
arr[i] = arr[i]/2;
}
}
// for(int j=0;j<60;j++){
// cout<<cumBit[0][j]<<” “;
// }cout<<endl;
for(int i=1;i<=n;i++){
for(int j=0;j<60;j++){
cumBit[i][j] += cumBit[i-1][j];
// cout<<cumBit[i][j]<<” ";
}
}
while(q–){
int k,l1,r1,l2,r2;
cin>>k>>l1>>r1>>l2>>r2;
int ans;
ll n1 = cumBit[r1][k] - cumBit[l1-1][k];
ll n0 = r1-l1+1-n1;
ll m1 = cumBit[r2][k] - cumBit[l2-1][k];
ll m0 = r2-l2+1-m1;
ans = n1m0 + n0m1;
cout<<ans<<endl;
}
}

int main(){
int t;
cin>>t;
while(t–){
solve();
}
return 0;
}

``````int n = 0;