#include #include #include #include using namespace std; typedef long long lint; typedef vectorvi; typedef pairpii; #define rep(i,n)for(int i=0;i<(int)(n);++i) vi kk[20]; int main(){ int n,m; cin>>n>>m; vi a(n); rep(i,n)cin>>a[i]; sort(a.rbegin(),a.rend()); rep(i,n){ int hi=1; while(a[i]>=1< occ; int x=0; for(int b=20-1;b>=0;--b){ int rem=m-ans.size(); int pick=((lint)kk[b].size()*(lint)rem+m-1)/m; pick=min(pick,(int)kk[b].size()); int bit=(x>>b)&1; if(pick%2==bit)pick--; if(pick<0)pick=0; rep(i,pick){ int w=kk[b][i]; ans.push_back(w); occ.insert(w); x^=w; } } int pos=n-1; while((int)ans.size()