You have three piles of candies: red, green and blue candies:

  * the first pile contains only red candies and there are r candies in it, 
  * the second pile contains only green candies and there are g candies in it, 
  * the third pile contains only blue candies and there are b candies in it. 



Each day Tanya eats exactly two candies of different colors. She is free to choose the colors of eaten candies: the only restriction that she can't eat two candies of the same color in a day.

Find the maximal number of days Tanya can eat candies? Each day she needs to eat exactly two candies.

Input

The first line contains integer t (1 ≤ t ≤ 1000) — the number of test cases in the input. Then t test cases follow.

Each test case is given as a separate line of the input. It contains three integers r, g and b (1 ≤ r, g, b ≤ 10^8) — the number of red, green and blue candies, respectively.

Output

Print t integers: the i-th printed integer is the answer on the i-th test case in the input.

Example

Input


6
1 1 1
1 2 1
4 1 1
7 4 10
8 1 4
8 2 8


Output


1
2
2
10
5
9

Note

In the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.

In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.

In the third example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and red and blue candies on the second day. Note, that two red candies will remain uneaten.

// AUTHOR : MAYANK SUNAL
import java.io.*;
import java.util.*;
import java.math.*;

public class Main {
	int p;
	int s;

	Main(int p, int s) {
		this.p = p;
		this.s = s;
	}

	static final Random random = new Random();
	static PrintWriter out = new PrintWriter((System.out));
	static Reader sc = new Reader();

	public static void main(String args[]) throws IOException {
		int t = sc.nextInt();
		while (t-- > 0) {
//        	CODE START FROM HERE 
			int r = sc.nextInt();
			int g = sc.nextInt();
			int b = sc.nextInt();
			int res = 0;
			int max = Math.max(r, Math.max(g, b));
			int min = Math.min(r, Math.min(g, b));
			int mid = r + g + b - max - min;
			int count = 0;
			
				if (mid + min == max) {
					System.out.println(max );
					continue;
				} else if (mid + min < max) {
					System.out.println(mid + min);
					continue;
				}
				if (mid + min > max) {
					int x = ceil(mid+min-max,2);
					mid -= x ;
					min -= x;
					count = count+ x;
					if(mid+min==max)
						System.out.println(max+count);
					else 
						System.out.println(min+mid+count);
				}

			}
		

	}

// }
// Fast Input Output
	static class Reader {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		public String next() {
			while (!st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String nextLine() {
			try {
				return br.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			return null;
		}

		public boolean hasNext() {
			String next = null;
			try {
				next = br.readLine();
			} catch (Exception e) {
			}
			if (next == null) {
				return false;
			}
			st = new StringTokenizer(next);
			return true;
		}

	}

	// EFFICIENT SORTING Ascending
	static void ruffleSortAsc(Integer[] a) {
		int n = a.length; // shuffle, then sort
		for (int i = 0; i < n; i++) {
			int oi = random.nextInt(n), temp = a[oi];
			a[oi] = a[i];
			a[i] = temp;
		}
		Arrays.sort(a);
	}

//	EFFICIENT SORTING Descending
	static void ruffleSortDesc(Integer[] a) {
		int n = a.length; // shuffle, then sort
		for (int i = 0; i < n; i++) {
			int oi = random.nextInt(n), temp = a[oi];
			a[oi] = a[i];
			a[i] = temp;
		}
		Arrays.sort(a, Collections.reverseOrder());
	}

	// Array Sum
	static long sum(Integer[] arr) {
		long sum = 0;
		for (int i : arr)
			sum += i;
		return sum;
	}

	// ArrayList Sum
	static long sumal(ArrayList<Integer> al) {
		long sum = 0;
		for (int i : al)
			sum += i;
		return sum;
	}

	// swap array elements
	static void swap(int arr1[], int arr2[], int i, int j) {
		int temp = arr1[i];
		arr1[i] = arr2[j];
		arr2[j] = temp;
	}

	// reading array value;
	static void read(Integer[] arr) {
		for (int i = 0; i < arr.length; i++)
			arr[i] = sc.nextInt();
		return;
	}

//    reading arraylistValue

	static void readal(List<Integer> l, int n) {
		for (int i = 0; i < n; i++)
			l.add(sc.nextInt());
		return;
	}

	// check for even odd
	static boolean isEven(long n) {
		return ((n & 1) != 1);
	}

	// max in a array
	static int max(Integer[] arr) {
		int max = Integer.MIN_VALUE;
		for (int i = 0; i < arr.length; i++)
			if (max < arr[i])
				max = arr[i];
		return max;
	}

//  print array
	static void printarr(Integer arr[]) {
		for (int i : arr)
			System.out.println(i);
	}

// ceil of two elements
	static int ceil(long l, int b) {
		return (int) Math.ceil(((double) l / (double) b));
	}

// floor of two elements
	static int floor(int a, int b) {
		return (int) Math.floor(((double) a / (double) b));
	}
}