#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
int t;
cin>>t;
while(t--){
int n, k;
cin>>n>>k;
vector<int>v(n,0);
bool sorted = true;
for(int i=0;i<n;i++){
int x;
cin>>x;
v[i]=x;
if(i>=1 and v[i]<v[i-1]){
sorted = false;
}
}
if(k>=2){
cout<<"YES"<<endl;
} else if(k==1 and sorted){
cout<<"YES"<<endl;
} else{
cout<<"NO"<<endl;
}
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgbGwgbG9uZyBsb25nIGludAoKaW50IG1haW4oKSB7CglpbnQgdDsKCWNpbj4+dDsKCXdoaWxlKHQtLSl7CgkJaW50IG4sIGs7CgkJY2luPj5uPj5rOwoJCXZlY3RvcjxpbnQ+dihuLDApOwoJCWJvb2wgc29ydGVkID0gdHJ1ZTsKCQlmb3IoaW50IGk9MDtpPG47aSsrKXsKCQkJaW50IHg7CgkJCWNpbj4+eDsKCQkJdltpXT14OwoJCQlpZihpPj0xIGFuZCB2W2ldPHZbaS0xXSl7CgkJCQlzb3J0ZWQgPSBmYWxzZTsKCQkJfQoJCX0KCQkKCQlpZihrPj0yKXsKCQkJY291dDw8IllFUyI8PGVuZGw7CgkJfSBlbHNlIGlmKGs9PTEgYW5kIHNvcnRlZCl7CgkJCWNvdXQ8PCJZRVMiPDxlbmRsOwoJCX0gZWxzZXsKCQkJY291dDw8Ik5PIjw8ZW5kbDsKCQl9Cgl9CglyZXR1cm4gMDsKfQ==