#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
ll t;
cin>>t;
while(t–)
{
ll n,k;
cin>>n>>k;
ll a[n+1];
a[0]=INT_MIN;
priority_queue <ll, vector, greater> PQ;
multimap<ll,ll>mp;
for(ll i=1;i<=n;i++)
{
cin>>a[i];
PQ.push(a[i]);
}
ll pos=1;
while(!PQ.empty())
{
ll x = PQ.top();
PQ.pop();
mp.insert({x,pos});
++pos;
}
/*
for(auto it=mp.begin();it!=mp.end();++it)
{
cout<first<<"->"<second<<endl;
}
*/
bool ans=true;
for(ll i=1;i<=n;i++)
{
auto itr = mp.find(a[i]);
ll x = i;
ll y = itr->second;
mp.erase(itr);
//cout<<x<<" "<<y<<endl;
if(x != y)
{
if( ((abs(x-y)%k)) != 0 )
{
ans=false;
break;
}
else continue;
}
else continue;
}
if(ans)
cout<<“yes\n”;
else cout<<“no\n”;
//cout<<mp.size()<<endl;
}
return 0;
}