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.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class a{
     static int[] count;
     // static int[] count1;
     static long[] arr;
     static char[] c;
     static long[] darr;
     static long x;
     static long maxl;
     // static long minl;
     static int mx = (int)1e6;
     static long mod = 998244353l;
     // static int minl = -1;
     static int n;
     static long a;
     static long b;
     // static long c;
     static long d;
     static long y;
     static long m;
     static long k;
     static String str;
     static Set<Long> set;
     static Set<Integer> list;
     static Map<Integer,List<Integer>> map;
     static StringBuilder sb;

     public static void solve(){

        Arrays.sort(arr);
        int s = 0;

        for(int i = 0; i < 3 ; i++){
            if(arr[i] > 0){
                s += 1;
                arr[i] -= 1;
            }
        }

        if(arr[2] > 0 && arr[1] > 0){
            s += 1;
            arr[2] -=1 ;
            arr[1] -= 1;
        }

        if(arr[2] > 0 && arr[0] > 0){
                    s += 1;
        
                arr[0] -=1 ;
                arr[2] -= 1;}

        if(arr[0] > 0 && arr[1] > 0){
                    s += 1;
        
                arr[0] -=1 ;
                arr[1] -= 1;}

        if(arr[0] > 0 && arr[1] > 0 && arr[2] > 0)
            s += 1;

        System.out.println(s);

     }

     public static void main(String[] args) {

            FastScanner sc = new FastScanner();

            int t = sc.nextInt();
            while(t > 0){
                 // set = new HashSet<>();
                 // map = new HashMap<>();
                
                // a = sc.nextLong();
                // b = sc.nextLong();
                // x = sc.nextLong();
                // y = sc.nextLong();
                // c = sc.nextLong();
                // d = sc.nextLong();

                 // long x = sc.nextLong();

                 // maxl = Integer.MIN_VALUE;


                // n = sc.nextInt();
                n = 3;
                //  // x = sc.nextLong();
                //  // a = sc.nextInt();
                //  // b = sc.nextInt();
                //  m = sc.nextLong();
                 // k = sc.nextLong();
                 // k = sc.nextInt();
                 // // x = sc.nextInt();
                 // c = sc.next().toCharArray();
                 // n = c.length;

                 // // // k = sc.nextInt();
                 
                arr = new long[n];
                for(int i = 0; i < n ; i++){
                    arr[i] = sc.nextLong();
                }


                 // darr = new long[n];
                 // for(int i = 0; i < n ; i++){
                 //     darr[i] = sc.nextLong();
                 // }
                 // boolean flag = false;
                 // str = sc.next();

                 // x = sc.nextInt();



                // System.out.println(!solve()?"Yes":"No");
                solve();
                 // System.out.println(solve());
                 // sb = new StringBuilder();
                 // sb.append(str);

                 t -= 1;
            }

     }

    public static int log(long n){
         if(n == 0)
             return 0;

         if(n == 1)
             return 0;
         if(n == 2)
             return 1;
         double num = Math.log(n);
         double den = Math.log(2);
         if(den == 0)
             return 0;
         return (int)(num/den);
     }

     public static void swap(int i,int j){
         long temp = arr[j];
         arr[j] = arr[i];
         arr[i] = temp;
     } 

    static final Random random=new Random();
    
    static void ruffleSort(long[] a) {
        int n=a.length;//shuffle, then sort 
        for (int i=0; i<n; i++) {
            int oi=random.nextInt(n);
            long temp=a[oi];
            a[oi]=a[i]; a[i]=temp;
        }
        Arrays.sort(a);
    }

     static class FastScanner {

                BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
                StringTokenizer st=new StringTokenizer("");
                String next() {
                        while (!st.hasMoreTokens())
                                try {
                                        st=new StringTokenizer(br.readLine());
                                } catch (IOException e) {
                                        e.printStackTrace();
                                }
                        return st.nextToken();
                }
                
                int nextInt() {
                        return Integer.parseInt(next());
                }
                int[] readArray(int n) {
                        int[] a=new int[n];
                        for (int i=0; i<n; i++) a[i]=nextInt();
                        return a;
                }
                long nextLong() {
                        return Long.parseLong(next());
                }
        }

}