// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#define dibs reserve
#define OVER9000 1234567890
#define tisic 47
#define soclose 10e-7
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define chocolate win
#define ff first
#define ss second
#define uint unsigned int
// mylittlepony
using namespace std;
int main() {
int T;
cin >> T;
for(int i =0; i < T; i++) {
int A[3];
cin >> A[0] >> A[1] >> A[2];
int ans =0;
if(A[0]+A[2] == 0 || A[1]+A[2] == 0 || A[0]+A[1] == 0) ans++;
else for(int j =0; j < 3; j++) for(int k =0; k < 3; k++) for(int l =0; l < 3; l++) {
if(k == j || k == l || j == l) continue;
if(A[j] == 0) continue;
if(A[k] == 0 && A[l] > 0) continue;
int x =min(A[j],min(A[k],A[l]));
if(A[j]-x > 1 || A[k]-x > 1 || A[l]-x > 1) continue;
if(A[j]-x == 0 && A[k]+A[l]-2*x > 0) continue;
if(A[k]-x == 0 && A[l]-x > 0) continue;
ans++;}
cout << ans << "\n";}
return 0;}
// look at my code
// my code is amazing
Ly8gaW9zdHJlYW0gaXMgdG9vIG1haW5zdHJlYW0KI2luY2x1ZGUgPGNzdGRpbz4KLy8gYml0Y2ggcGxlYXNlCiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPHNldD4KI2luY2x1ZGUgPG1hcD4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPHF1ZXVlPgojaW5jbHVkZSA8c3RhY2s+CiNpbmNsdWRlIDxhbGdvcml0aG0+CiNkZWZpbmUgZGlicyByZXNlcnZlCiNkZWZpbmUgT1ZFUjkwMDAgMTIzNDU2Nzg5MAojZGVmaW5lIHRpc2ljIDQ3CiNkZWZpbmUgc29jbG9zZSAxMGUtNwojZGVmaW5lIEFMTF9USEUoQ0FLRSxMSUUpIGZvcihhdXRvIExJRSA9Q0FLRS5iZWdpbigpOyBMSUUgIT0gQ0FLRS5lbmQoKTsgTElFKyspCiNkZWZpbmUgY2hvY29sYXRlIHdpbgojZGVmaW5lIGZmIGZpcnN0CiNkZWZpbmUgc3Mgc2Vjb25kCiNkZWZpbmUgdWludCB1bnNpZ25lZCBpbnQKLy8gbXlsaXR0bGVwb255CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgkKaW50IG1haW4oKSB7CiAgICBpbnQgVDsKICAgIGNpbiA+PiBUOwogICAgZm9yKGludCBpID0wOyBpIDwgVDsgaSsrKSB7CiAgICAJaW50IEFbM107CiAgICAJY2luID4+IEFbMF0gPj4gQVsxXSA+PiBBWzJdOwogICAgCWludCBhbnMgPTA7CiAgICAJaWYoQVswXStBWzJdID09IDAgfHwgQVsxXStBWzJdID09IDAgfHwgQVswXStBWzFdID09IDApIGFucysrOwogICAgCWVsc2UgZm9yKGludCBqID0wOyBqIDwgMzsgaisrKSBmb3IoaW50IGsgPTA7IGsgPCAzOyBrKyspIGZvcihpbnQgbCA9MDsgbCA8IDM7IGwrKykgewogICAgCQlpZihrID09IGogfHwgayA9PSBsIHx8IGogPT0gbCkgY29udGludWU7CiAgICAJCWlmKEFbal0gPT0gMCkgY29udGludWU7CiAgICAJCWlmKEFba10gPT0gMCAmJiBBW2xdID4gMCkgY29udGludWU7CiAgICAJCWludCB4ID1taW4oQVtqXSxtaW4oQVtrXSxBW2xdKSk7CiAgICAJCWlmKEFbal0teCA+IDEgfHwgQVtrXS14ID4gMSB8fCBBW2xdLXggPiAxKSBjb250aW51ZTsKICAgIAkJaWYoQVtqXS14ID09IDAgJiYgQVtrXStBW2xdLTIqeCA+IDApIGNvbnRpbnVlOwogICAgCQlpZihBW2tdLXggPT0gMCAmJiBBW2xdLXggPiAwKSBjb250aW51ZTsKICAgIAkJYW5zKys7fQogICAgCWNvdXQgPDwgYW5zIDw8ICJcbiI7fQogICAgcmV0dXJuIDA7fQogICAgICAgIAovLyBsb29rIGF0IG15IGNvZGUKLy8gbXkgY29kZSBpcyBhbWF6aW5n