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 \le t \le 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 \le r, g, b \le 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.

Difficulty: interview

Starter code:

Solutions:
n = int(input())

for _ in range(n):
    a, b, c = list(map(int, input().split()))

    print(min((a+b+c)//2, a+b, a+c, b+c))


t = int(input())
for _ in range(t):
    li = list(map(int, input().split()))
    li = sorted(li)
    if li[0] + li[1] <= li[2]:
        print(li[0] + li[1])
    else:
        print(sum(li) // 2)

for _ in range(int(input())):
	l = sorted(map(int, input().split()))
	print(min(sum(l) // 2, l[0] + l[1]))

for _ in range(int(input())):
	l=sorted(list(map(int,input().split())))
	print(min(l[0]+l[1],sum(l)//2))

t=int(input())
for _ in range(t):
    a,b,c=list(map(int,input().split()))
    a,b,c=sorted([a,b,c])
    aa=a
    bb=b
    cc=c
    d=c-b
    c-=min(d,a)
    a-=min(a,d)
    b-=min(a//2,0)
    a-=min(a//2,0)
    c-=min(a,0)
    a-=min(a,0)
    b,c=sorted([b,c])
    c-=b
    b=0
    print((aa+bb+cc-c)//2)


import sys
input = sys.stdin.readline

t=int(input())
for testcases in range(t):
    r,g,b=sorted(map(int,input().split()))

    if b>r+g:
        print(r+g)
    else:
        print((r+g+b)//2)

    


t = int(input())
for i in range (t):
    r, g, b = list(map(int,input().split()))
    maxi = max(r, g, b)
    total = r + g + b
    if 2 * maxi > total:
        print(total - maxi)
    else:
        print(total//2)

q=int(input())
for i in range(q):
    r=[int(x) for x in input().split()]
    print(min(int(sum(r)/2),sum(r)-max(r)))

T = int(input())
for t in range(T):
    a, b, c = sorted(map(int, input().strip().split()))
    d = c - b
    v = a
    if d > a:
        v += min(c - a, b)
    else:
        a -= d
        c -= d + a // 2
        b -= a - a // 2
        v += min(c, b)
    print(v)


for i in range(int(input())):
	a = sorted([int(i) for i in input().split()])
	print(min(a[0]+a[1], sum(a)//2))


t = int(input())

for _ in range(t):
    r, g, b = sorted(map(int, input().split()))
    s = sum([r, g, b])
    print(min([r + g, s // 2]))


def solve():
    r,g,b = map(int, input().split())
    a,b,c = sorted([r,g,b])
    if a+b <= c:
        ans = a+b
    else:
        ans = a+b+c
        ans //= 2
    print(ans)

t = int(input())
for i in range(t):
    solve()

# https://codeforces.com/contest/1263/problem/A

t = int(input())
for i in range(t):
    rgb = list(map(int, input().split()))
    rgb.sort()
    ans = min(sum(rgb) // 2, sum(rgb[:2]))
    print(ans)


t=int(input())
for ij in range(0,t):
	l=list(map(int,input().split()))
	l=sorted(l)
	if l[2]>l[1]+l[0]:
		print(l[1]+l[0])
	else:
		print(sum(l)//2)

a = int(input())
for i in range(a):
    x, y, z = map(int, input().split())
    x, y, z = sorted([x, y, z])
    k = z - y
    if k == 0:
        y += x//2
        print(y)
    elif k > x:
        y += x
        print(y)
    else:
        x -= z - y
        y = z
        z += x//2
        print(z)

import sys

# sys.stdin = open("in.txt")
for _ in range(int(input())):
    a, b, c = sorted(list(map(int, input().split())))
    print((a + b + c - max(0, c - (a + b))) // 2)
    # res = min(a, b)
    # a -= res
    # b -= res
    # res2 = min(b, c)
    # b -= res2
    # c -= res2
    # res3 = min(a, c)
    # a -= res3
    # c -= res3
    # print(res + res2 + res3)


n = int(input())
for i in range(n):
    a = sorted(list(map(int, input().split())))
    if a[2] >= a[0]+a[1]:
        print(a[0]+a[1])
    else:
        print(a[2]+(a[0]+a[1]-a[2])//2)

sp = lambda: list(map(int, input().split()))
si = lambda: int(input())

TESTCASES = int(input())
for tc in range(TESTCASES):
    r,g,b=sorted(sp())
    if b>r+g: b=r+g
    print((r+g+b)//2)

t = int(input())
for i in range(t):
    r, g, b = list(map(int, input().split()))
    if 2 * max(r, g, b) >= (r + g + b):
        print(r + g + b - max(r, g, b))
    else:
        print((r + g + b) // 2)


t=int(input())
for i in range(t):
  r,g,b = map(int,input().split())
  arr = [r,g,b]
  arr.sort()
  diff = arr[2]-arr[1]
  arr[2] -= arr[0]
  if arr[2] < arr[1]:
    arr[2] = int((arr[1]+arr[2])/2)
    arr[1] = arr[2]
  print(arr[0]+min(arr[2],arr[1]))

for _ in range(int(input())):
    l =list( map( int, input().split()) )
    l.sort()
    s, m , b = l
    a = s
    c = min( s, b - m )
    s -= c
    b -= c
    b -= s // 2
    m -= s - s // 2
    a += min( m, b )
    print( a )



n = int(input())
while n != 0:
    n -= 1
    a = list(map(int, input().split()))
    a.sort()
    if a[0] + a[1] >= a[2]:
        print(sum(a)//2)
    else:
        print(a[0] + a[1])

import sys


# inf = open('input.txt', 'r')
# reader = (map(int, line.split()) for line in inf)
reader = (list(map(int, s.split())) for s in sys.stdin)

def sweets(r, g, b):
    total = g - r
    g -= total
    b -= total
    if b > r + g:
        total += r + g
    else:
        total += (r + b + g) // 2
        
    return total

t, = next(reader)
for _ in range(t):
    r, g, b = sorted(list(next(reader)))
    ans = sweets(r, g, b)
    print(ans)
    
# inf.close()


#!/usr/bin/env python3
import sys
input = sys.stdin.readline

t = int(input())
for i in range(t):
    candy = [int(item) for item in input().split()]
    candy.sort(reverse=True)
    total = sum(candy)
    if candy[0] <= candy[1] + candy[2]:
        print((total - total % 2) // 2)
    else:
        print(total - (candy[0] - candy[1] - candy[2]) // 2)

from math import *
from collections import *
import sys
sys.setrecursionlimit(10**9)

t = int(input())
for y in range(t):
	r,g,b = list(map(int,input().split()))
	m = max(r,g,b)
	if(r + g + b - m >= m):
		ans = (r+g+b)//2
	else:
		ans = r+g+b - m
	print(ans)