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.
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;


public class Main {

    static void solve() {
        Scanner scan = new Scanner(System.in);
        int t = scan.nextInt();
        for(int i=0;i<t;i++) {
            int r = scan.nextInt();
            int g = scan.nextInt();
            int b = scan.nextInt();

            int res = 0;
            int[] arr = new int[]{r,g,b};
            Arrays.sort(arr);
            if(arr[0] + arr[1] < arr[2]) {
                res = arr[0] + arr[1];
            }else{
                res = (arr[0] + arr[1] + arr[2])/2;
            }
            System.out.println(res);

        }
//            System.out.println();
    }


    public static void main(String[] args) {
            solve();
        //        Main m = new Main();
        //        Scanner scan = new Scanner(System.in);

        //        long n = scan.nextLong();
        //        long r = scan.nextLong();
        //        List<Long> list = new ArrayList<>();
        ////        int[] arr = new int[n];
        //        for (long i=0;i<n;i++){
        //            list.add(scan.nextLong());
        //        }
//            System.out.println(ch);
        //        solve(n, arr);
        //        scan.close();
    }


    static int[] countSort() {
        int[] input = new int[]{1, 4, 1, 2, 7, 5, 2};
        int[] output = new int[input.length];
        int[] count = new int[8];

        for (int i = 0; i < input.length; i++) {
            count[input[i]]++;
        }

        //forgot to sum those values, iterate over count
        int sum = 0;
        for (int i = 0; i < count.length; i++) {
            sum += count[i];
            count[i] = sum;
        }

        for (int i = 0; i < input.length; i++) {
            int pos = count[input[i]];
            output[pos - 1] = input[i];
            count[input[i]]--;
        }
        return output;
    }


    static class LRUCache {
        Map<Integer, Node> map;
        Node front;
        Node tail;
        int capacity;

        public LRUCache(int capacity) {
            map = new HashMap<>(capacity);
            this.capacity = capacity;
        }

        public int get(int key) {
            if (!map.containsKey(key)) {
                return -1;
            }
            Node node = map.get(key);
            if (node == front) {
                return front.data;
            }
            if (node == tail) {
                tail = node.prev;
            }
            front.prev = node;
            node.prev.next = node.next;
            if (node.next != null) {
                node.next.prev = node.prev;
            }
            node.next = front;
            node.prev = null;
            front = node;

            return front.data;
        }

        public void put(int key, int value) {
            Node node = new Node(key, value);
            ;
            if (front == null) {
                front = node;
                tail = node;
                map.put(key, node);
                return;
            }
            if (map.containsKey(key)) {
                node = map.get(key);
                node.data = value;
                if (node == front) {
                    map.put(key, node);
                    return;
                }
                if (node == tail) {
                    tail = node.prev;
                }
                front.prev = node;
                node.prev.next = node.next;
                if (node.next != null) {
                    node.next.prev = node.prev;
                }
                node.next = front;
                node.prev = null;
                front = node;
                map.put(key, node);
            } else if (map.size() < capacity) {
                front.prev = node;
                node.next = front;
                node.prev = null;
                front = node;
                map.put(key, node);

            } else {
                //remove a tail, insert to front
                map.remove(tail.key);
                if (tail.prev != null) {
                    tail.prev.next = null;
                }
                tail = tail.prev;

                front.prev = node;
                node.next = front;
                node.prev = null;
                front = node;
                map.put(key, node);
            }
        }
    }

    static class Node {
        int key;
        int data;
        Node next;
        Node prev;

        Node(int key, int data) {
            this.key = key;
            this.data = data;
        }
    }

    static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }

    static class Trie {
        void add(String word) {

        }

        boolean search(String w) {
            return false;
        }
    }

    static class Node1 {
        public int val;
        public List<Node1> children;

        public Node1() {
        }

        public Node1(int _val, List<Node1> _children) {
            val = _val;
            children = _children;
        }
    }

    ;

    static class TrieNode {

    }

    static class KvNode implements Comparable<KvNode> {
        String key;
        int freq;

        public KvNode(String key, int freq) {
            this.key = key;
            this.freq = freq;
        }

        @Override
        public int compareTo(KvNode o) {
            if (this.key.equals(o.key)) {
                return 0;
            }
            return Integer.compare(o.freq, this.freq);
        }
    }

    static class ListNode {
        int val;
        ListNode next;

        ListNode(int x) {
            val = x;
        }
    }

}
