#include #include using std::sort; int a[2000],b[2000]; int main() { #ifdef local freopen("card_test.txt","r",stdin); #endif int T,n,m,sumA,sumB; scanf("%d",&T); for(int k = 1;k <= T;++k) { scanf("%d%d",&n,&m); for(int i = 0;i < n;++i) scanf("%d",a+i); for(int i = 0;i < n;++i) scanf("%d",b+i); sort(a,a+n); sort(b,b+n); sumA = a[0],sumB = b[n - 1]; for(int i = 1;i < m;++i) sumA += a[i]; for(int i = 1;i < m;++i) sumB += b[n - i - 1]; if (sumA > sumB) puts("YES"); else puts("NO"); } fclose(stdin);fclose(stdout); return 0; }