import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt();
while (t-- > 0) {
int a1 = scanner.nextInt();
int a2 = scanner.nextInt();
int b1 = scanner.nextInt();
int b2 = scanner.nextInt();
int count = 0;
// Alex的两种翻牌顺序
int[][] alexOrders = {{a1, a2}, {a2, a1}};
// Bob的两种翻牌顺序
int[][] bobOrders = {{b1, b2}, {b2, b1}};
// 遍历所有可能的翻牌顺序组合
for (int[] alex : alexOrders) {
for (int[] bob : bobOrders) {
// 计算双方赢得的回合数
int alexWins = 0;
int bobWins = 0;
if (alex[0] > bob[0]) {
alexWins++;
} else if (alex[0] < bob[0]) {
bobWins++;
}
if (alex[1] > bob[1]) {
alexWins++;
} else if (alex[1] < bob[1]) {
bobWins++;
}
// 当Alex赢得的回合数多于Bob时,才是Alex获胜
if (alexWins > bobWins) {
count++;
}
}
}
System.out.println(count);
}
scanner.close();
}
}