I can't able to understand why my apporach is giving wrong answer

question link
#include<bits/stdc++.h>
using namespace std;
priority_queue<pair<long long, long long> > pq;
void solve(vector< pair<long long,long long> >a){
int n=a.size();
long long s=a[n-1].second,ele,p;
for(int i=0;i<n;i++){
p=pow(2,s);
ele=(a[i].first)^p;
if (ele!=0)
pq.push(make_pair(ele,log2(ele)));
}
}
int main() {
int t,n,k;
long long x,step,count;
long long arr[100000];
cin>>t;
while(t–){
cin>>n>>k;
for(int i=0;i<n;i++){
cin>>x;
arr[i]=x;
if (arr[i]!=0)
pq.push(make_pair(arr[i],log2(arr[i])));
}
step=0;
pair<long long,long long> top;
while (!pq.empty()){
top=pq.top();
pq.pop();
vector <pair<long long,long long>> a;
a.push_back(make_pair(top.first,top.second));
count=1;
while ( (!pq.empty()) && (a[0].second==pq.top().second) && count<k){
top=pq.top();
pq.pop();
a.push_back(make_pair(top.first,top.second));
count++;
}
solve(a);
step++;
}
cout<<step<<"\n";

}

}

He solved it.

Ok got it thanks!!