Tired of boring office work, Denis decided to open a fast food restaurant.

On the first day he made a portions of dumplings, b portions of cranberry juice and c pancakes with condensed milk.

The peculiarity of Denis's restaurant is the procedure of ordering food. For each visitor Denis himself chooses a set of dishes that this visitor will receive. When doing so, Denis is guided by the following rules:

  * every visitor should receive at least one dish (dumplings, cranberry juice, pancakes with condensed milk are all considered to be dishes); 
  * each visitor should receive no more than one portion of dumplings, no more than one portion of cranberry juice and no more than one pancake with condensed milk; 
  * all visitors should receive different sets of dishes. 



What is the maximum number of visitors Denis can feed?

Input

The first line contains an integer t (1 ≤ t ≤ 500) — the number of test cases to solve.

Each of the remaining t lines contains integers a, b and c (0 ≤ a, b, c ≤ 10) — the number of portions of dumplings, the number of portions of cranberry juice and the number of condensed milk pancakes Denis made.

Output

For each test case print a single integer — the maximum number of visitors Denis can feed.

Example

Input

7
1 2 1
0 0 0
9 1 7
2 2 3
2 3 2
3 2 2
4 4 4


Output

3
0
4
5
5
5
7

Note

In the first test case of the example, Denis can feed the first visitor with dumplings, give the second a portion of cranberry juice, and give the third visitor a portion of cranberry juice and a pancake with a condensed milk.

In the second test case of the example, the restaurant Denis is not very promising: he can serve no customers.

In the third test case of the example, Denise can serve four visitors. The first guest will receive a full lunch of dumplings, a portion of cranberry juice and a pancake with condensed milk. The second visitor will get only dumplings. The third guest will receive a pancake with condensed milk, and the fourth guest will receive a pancake and a portion of dumplings. Please note that Denis hasn't used all of the prepared products, but is unable to serve more visitors.
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Arrays;
import java.util.LinkedHashSet;

public class Main {
    public static void main(String[] args) throws UnsupportedEncodingException, IOException, Exception
    {
    Reader.init(System.in);
    StringBuilder out = new StringBuilder();
    PrintWriter pw=new PrintWriter(System.out);
    
    int x=Reader.nextInt();
    
    while(x-->0)
    {
        int a=Reader.nextInt(),b=Reader.nextInt(),c=Reader.nextInt();
        int arr[]={a,b,c};
        
        int cnt=0;
        LinkedHashSet<String>set=new LinkedHashSet<>();
        Arrays.sort(arr);
        int temp=arr[0];
        arr[0]=arr[2];
        arr[2]=temp;
        for(int y=0;y<3;y++)
            
        {
            if(arr[y]>0)
            {cnt+=1;arr[y]--;}
        }
        boolean flag=false,flag2=false;
       // System.out.println(cnt);
        if(cnt==0)pw.println("0");
        else
        {
               
                if(arr[0]>0)
                    {
                        if(arr[1]>0){flag=true;cnt++;arr[1]--;arr[0]--;}
                        if(arr[0]>0)
                        {if(arr[2]>0){flag2=true;cnt++;arr[2]--;arr[0]--;}}
                       
                    }
                int y=1;
                if(arr[2]>0&&arr[1]>0){arr[1]--;arr[2]--;cnt++;}
                
                if(arr[0]>0&&arr[1]>0&&arr[2]>0)cnt++;
                
                 pw.println(cnt);
        }
                        
            
        
       
    }
    
    //System.out.println("uhi");
    
    
    
    pw.close();
    }
    
}
class Reader {
 
    static BufferedReader reader;
    static StringTokenizer tokenizer;
 
    static void init(InputStream input) throws UnsupportedEncodingException {
        reader = new BufferedReader(
                new InputStreamReader(input, "UTF-8"));
        tokenizer = new StringTokenizer("");
    }
 
    static void init(String url) throws FileNotFoundException {
        reader = new BufferedReader(new FileReader(url));
        tokenizer = new StringTokenizer("");
    }
 
    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }
 
    static String nextLine() throws IOException {
        return reader.readLine();
    }
 
    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
 
    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
 
    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}
