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.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;

public class D {
	public static ArrayList<Integer>[] adj;

	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		InputReader s = new InputReader(System.in);
		PrintWriter p = new PrintWriter(System.out);
		int t = s.nextInt();
		while (t-- > 0) {
			int[] arr = new int[3];
			for (int i = 0; i < 3; i++)
				arr[i] = s.nextInt();
			Arrays.sort(arr);
			int ans = 0;
			if (arr[0] == 0) {
				if (arr[1] == 1)
					ans = 2;
				else if (arr[1] >= 2)
					ans = 3;
				else {
					if (arr[2] == 0)
						ans = 0;
					else
						ans = 1;
				}
			} else if (arr[0] == 1) {
				ans = 3;
				arr[1]--;
				arr[2]--;
				if (arr[1] > 0)
					ans++;
			} else if (arr[0] == 2) {
				ans = 4;
				arr[0] = 0;
				arr[1]--;
				arr[2] -= 2;
				Arrays.sort(arr);
				if (arr[1] > 0)
					ans++;
			} else if (arr[0] == 3) {
				ans = 6;
			} else {
				ans = 7;
			}
			p.println(ans);
		}
		p.flush();
		p.close();
	}

	public static String large(int m, int n) {
		StringBuilder ans = new StringBuilder();
		while (n - 9 >= 0) {
			n -= 9;
			ans.append(9);
			m--;
		}
		if (n == 0 && m == 0) {
			return ans.toString();
		}
		int val = n;
		if (val > 9 || val < 0)
			return "-1";
		n -= val;
		m--;
		ans.append(val);
		if (m < 0)
			return "-1";
		for (int i = 0; i < m; i++) {
			ans.append(0);
		}
		return ans.toString();
	}

	public static String small(int m, int n) {
		StringBuilder ans = new StringBuilder();
		if (9 * (m - 1) > n - 1) {
			ans.append(1);
			m--;
			n--;
		} else {
			int val = n - 9 * (m - 1);
			if (val > 9 || val < 0)
				return "-1";
			ans.append(val);
			m--;
			n -= val;
		}
		while (9 * (m - 1) >= n) {
			ans.append(0);
			m--;
		}
		if (n == 0 && m == 0) {
			return ans.toString();
		}
		int val = n - 9 * (m - 1);
		if (val > 9 || val < 0)
			return "-1";
		ans.append(val);
		m--;
		if (m < 0)
			return "-1";
		for (int i = 0; i < m; i++) {
			ans.append(9);
		}
		return ans.toString();
	}

	static class pair implements Comparable<pair> {
		Character ch;
		int index;

		pair(Character c, int index) {
			ch = c;
			this.index = index;
		}

		public int compareTo(pair p1) {
			if (ch.compareTo(p1.ch) == 0) {
				return index - p1.index;
			} else {
				return ch.compareTo(p1.ch);
			}
		}
	}

	static long gcd(long a, long b) {
		if (b == 0)
			return a;
		return gcd(b, a % b);
	}

	public static ArrayList<Long> Divisors(long n) {
		ArrayList<Long> div = new ArrayList<>();

		for (long i = 1; i <= Math.sqrt(n); i++) {
			if (n % i == 0) {
				div.add(i);
				if (n / i != i)
					div.add(n / i);
			}
		}
		return div;
	}

	public static int BinarySearch(long[] a, long k) {
		int n = a.length;
		int i = 0, j = n - 1;
		int mid = 0;

		if (k < a[0])
			return 0;
		else if (k >= a[n - 1])
			return n;
		else {
			while (j - i > 1) {
				mid = (i + j) / 2;

				if (k >= a[mid])
					i = mid;
				else
					j = mid;
			}
		}

		return i + 1;
	}

	public static long GCD(long a, long b) {
		if (b == 0)
			return a;
		else
			return GCD(b, a % b);
	}

	public static long LCM(long a, long b) {
		return (a * b) / GCD(a, b);
	}

//	static class pair implements Comparable<pair> {
//		Integer x, y;
//
//		pair(int x, int y) {
//			this.x = x;
//			this.y = y;
//		}
//
//		public int compareTo(pair o) {
//			int result = x.compareTo(o.x);
//			if (result == 0)
//				result = y.compareTo(o.y);
//
//			return result;
//		}
//
//		public String toString() {
//			return x + " " + y;
//		}
//
//		public boolean equals(Object o) {
//			if (o instanceof pair) {
//				pair p = (pair) o;
//				return p.x - x == 0 && p.y - y == 0;
//			}
//			return false;
//		}
//
//		public int hashCode() {
//			return new Long(x).hashCode() * 31 + new Long(y).hashCode();
//		}
//	}

	static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int snext() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}

		public String readString() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}

	static class CodeX {
		public static void sort(long arr[]) {
			merge_sort(arr, 0, arr.length - 1);
		}

		private static void merge_sort(long A[], long start, long end) {
			if (start < end) {
				long mid = (start + end) / 2;
				merge_sort(A, start, mid);
				merge_sort(A, mid + 1, end);
				merge(A, start, mid, end);
			}

		}

		private static void merge(long A[], long start, long mid, long end) {
			long p = start, q = mid + 1;
			long Arr[] = new long[(int) (end - start + 1)];
			long k = 0;

			for (int i = (int) start; i <= end; i++) {
				if (p > mid)
					Arr[(int) k++] = A[(int) q++];

				else if (q > end)
					Arr[(int) k++] = A[(int) p++];

				else if (A[(int) p] < A[(int) q])
					Arr[(int) k++] = A[(int) p++];

				else
					Arr[(int) k++] = A[(int) q++];
			}
			for (int i = 0; i < k; i++) {
				A[(int) start++] = Arr[i];
			}

		}

	}

}