
3)

#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	cin >> t;
	while (t--) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		int counter = 0;
		if (b > a) counter++;
		if (c > a) counter++;
		if (d > a) counter++;
		cout << counter << '\n';
	}
	return 0;
}