#include<bits/stdc++.h>
using namespace std;
int a[5],b[5],c[5],t,win,lose,n=4,w1,w2,l1,l2;
bool f;
int main(){
cin>>t;
while(t--){
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<=n;i++)cin>>b[i];
f=win=lose=w1=w2=l1=l2=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++)
if(a[i]>b[j])win++;
else lose++;
}
if(win==lose){
cout<<"yes"<<"\n";
continue;
}
if(win<lose){
for(int i=1;i<=n;i++){
swap(a[i],b[i]);
}
}
for(c[1]=1;c[1]<=10;c[1]++){
for(c[2]=c[1];c[2]<=10;c[2]++){
for(c[3]=c[2];c[3]<=10;c[3]++){
for(c[4]=c[3];c[4]<=10;c[4]++){
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(c[i]<b[j])w1++;
if(c[i]>b[j])l1++;
if(c[i]<a[j])l2++;
if(c[i]>a[j])w2++;
}
}
// printf("c[%d]=%d c[%d]=%d c[%d]=%d c[%d]=%d \n w1=%d l1=%d\n w2=%d l2=%d\n",1,c[1],2,c[2],3,c[3],4,c[4],w1,l1,w2,l2);
if(w1>l1&&w2>l2)f=1;
if(f==1)break;
w1=l1=w2=l2=0;
}
if(f==1)break;
}
if(f==1)break;
}
if(f==1)break;
}
if(f==1)cout<<"yes\n";
else cout<<"no\n";
}
return 0;
}
P8091 help
36