// Arup Guha
// 1/20/2024
// Solution to USACO Jan Bronze Problem: Non-Transitive Dice
// Used to illustrate how to use USACO

import java.util.*;

public class dice {

	public static void main(String[] args) {
		
		Scanner stdin = new Scanner(System.in);
		int nC = stdin.nextInt();
		
		// Process cases.
		for (int loop=0; loop<nC; loop++) {
		
			// Read in both dice.
			int[] team1 = new int[4];
			for (int i=0; i<4; i++)
				team1[i] = stdin.nextInt();
			int[] team2 = new int[4];
			for (int i=0; i<4; i++)
				team2[i] = stdin.nextInt();
			
			// Will change to true if we find a die that works.
			boolean flag = false;
			
			// Try each die.
			for (int i=0; i<10000; i++) {
				
				// Get the die that corresponds to this number.
				int[] team3 = getDie(i);
				
				// Hey we found one that works, get out.
				if (nontransitive(team1, team2, team3)) {
					flag = true;
					break;
				}
			}
			
			// Ta da!
			if (flag)
				System.out.println("yes");
			else
				System.out.println("no");
		}
	}
	
	// 0 <= n < 10000
	public static int[] getDie(int n) {
		
		// Peel off each digit and store in res.
		int[] res = new int[4];
		for (int i=0; i<4; i++) {
			res[i] = n%10+1;
			n = n/10;
		}
		return res;
	}
	
	public static boolean nontransitive(int[] t1, int[] t2, int[] t3) {
		
		// Eh, not great, oh well...
		int s1 = 0, s2 = 0, s3 = 0;
		if (beat(t1, t2)) s1++;
		if (beat(t1, t3)) s1++;
		if (beat(t2, t1)) s2++;
		if (beat(t2, t3)) s2++;
		if (beat(t3, t1)) s3++;
		if (beat(t3, t2)) s3++;	

		// This makes it non-transitive.
		return s1 == 1 && s2 == 1 && s3 == 1;
	}
	
	// Returns true if t1 beats t2.
	public static boolean beat(int[] t1, int[] t2) {
		
		int s1 = 0, s2 = 0;
		for (int i=0; i<t1.length; i++) {
			for (int j=0; j<t2.length; j++) {
				if (t1[i] > t2[j]) s1++;
				if (t2[j] > t1[i]) s2++;
			}
		}
		
		// This is a win for t1.
		return s1 > s2;
	}
}