#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pci = pair<char, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
const ll infll = 1e18 + 3;
const int maxn = 1e6 + 77;
const int nmax = 1e6 + 577;
const ll basell = 1e18 + 3;
const ld eps = 1e-7;
const int inf = 1009000999;
const int nv = 100505;
const int baseint = 1000200013;
const ld PI = acos(-1.0);
inline bool EQ(ld a, ld b) { return fabs(a - b) < 1e-11; }
inline bool IF(int a, int b, int c) { return (a >= b && a <= c); }
inline bool IFS(int a, int b, int c) { return (a > b && a < c); }
template <typename T>
inline istream &operator>>(istream &_in, vector<T> &_v) {
  for (auto &_i : _v) {
    _in >> _i;
  }
  return _in;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const vector<T> &_v) {
  if (_v.empty()) {
    return _out;
  }
  _out << _v.front();
  for (auto _it = ++_v.begin(); _it != _v.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const pair<T, U> &_p) {
  _out << _p.first << ' ' << _p.second;
  return _out;
}
template <typename T, typename U>
inline istream &operator>>(istream &_in, pair<T, U> &_p) {
  _in >> _p.first >> _p.second;
  return _in;
}
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
int inline solve() {
  ios::sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
  int T;
  cin >> T;
  while ((T--)) {
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b) swap(a, b);
    if (b > c) swap(b, c);
    if (a > c) swap(a, c);
    int k = 0;
    int t = 0;
    while (b > 0) {
      if (a == b && b == c) {
        if ((b % 2 == 1)) t++;
        b -= (b % 2 == 1);
        t += (b / 2) * 3;
        break;
      }
      if (a == 0) {
        t += (b);
        break;
      }
      if (a == b) {
        int d = min(c - b, min(a, c / 2));
        t += 2 * d;
        a -= d;
        b -= d;
        c -= 2 * d;
        if (a > b) swap(a, b);
        if (b > c) swap(b, c);
        if (a > c) swap(a, c);
        continue;
      }
      if (b == c) {
        int d = b - a;
        t += d;
        b -= d;
        c -= d;
        if (a > b) swap(a, b);
        if (b > c) swap(b, c);
        if (a > c) swap(a, c);
        continue;
      }
      k = (b - a);
      t += k;
      c -= k;
      b -= k;
      if (a == b && b == c) {
        if ((b % 2 == 1)) t++;
        b -= (b % 2 == 1);
        t += (b / 2) * 3;
        break;
      }
      if (a == b) {
        int d = min(c - b, min(a, c / 2));
        t += 2 * d;
        a -= d;
        b -= d;
        c -= 2 * d;
        if (a > b) swap(a, b);
        if (b > c) swap(b, c);
        if (a > c) swap(a, c);
        continue;
      }
      if (b == c) {
        int d = b - a;
        t += d;
        b -= d;
        c -= d;
        if (a > b) swap(a, b);
        if (b > c) swap(b, c);
        if (a > c) swap(a, c);
        continue;
      }
      if (b != 0) {
        t++;
        b--;
        c--;
      }
      if (a > b) swap(a, b);
      if (b > c) swap(b, c);
      if (a > c) swap(a, c);
    }
    cout << t << '\n';
  }
  return 0;
}
int32_t main() {
  solve();
  return 0;
}

### Prompt

Create a solution in Cpp for the following problem:

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.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pci = pair<char, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
const ll infll = 1e18 + 3;
const int maxn = 1e6 + 77;
const int nmax = 1e6 + 577;
const ll basell = 1e18 + 3;
const ld eps = 1e-7;
const int inf = 1009000999;
const int nv = 100505;
const int baseint = 1000200013;
const ld PI = acos(-1.0);
inline bool EQ(ld a, ld b) { return fabs(a - b) < 1e-11; }
inline bool IF(int a, int b, int c) { return (a >= b && a <= c); }
inline bool IFS(int a, int b, int c) { return (a > b && a < c); }
template <typename T>
inline istream &operator>>(istream &_in, vector<T> &_v) {
  for (auto &_i : _v) {
    _in >> _i;
  }
  return _in;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const vector<T> &_v) {
  if (_v.empty()) {
    return _out;
  }
  _out << _v.front();
  for (auto _it = ++_v.begin(); _it != _v.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const pair<T, U> &_p) {
  _out << _p.first << ' ' << _p.second;
  return _out;
}
template <typename T, typename U>
inline istream &operator>>(istream &_in, pair<T, U> &_p) {
  _in >> _p.first >> _p.second;
  return _in;
}
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
int inline solve() {
  ios::sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
  int T;
  cin >> T;
  while ((T--)) {
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b) swap(a, b);
    if (b > c) swap(b, c);
    if (a > c) swap(a, c);
    int k = 0;
    int t = 0;
    while (b > 0) {
      if (a == b && b == c) {
        if ((b % 2 == 1)) t++;
        b -= (b % 2 == 1);
        t += (b / 2) * 3;
        break;
      }
      if (a == 0) {
        t += (b);
        break;
      }
      if (a == b) {
        int d = min(c - b, min(a, c / 2));
        t += 2 * d;
        a -= d;
        b -= d;
        c -= 2 * d;
        if (a > b) swap(a, b);
        if (b > c) swap(b, c);
        if (a > c) swap(a, c);
        continue;
      }
      if (b == c) {
        int d = b - a;
        t += d;
        b -= d;
        c -= d;
        if (a > b) swap(a, b);
        if (b > c) swap(b, c);
        if (a > c) swap(a, c);
        continue;
      }
      k = (b - a);
      t += k;
      c -= k;
      b -= k;
      if (a == b && b == c) {
        if ((b % 2 == 1)) t++;
        b -= (b % 2 == 1);
        t += (b / 2) * 3;
        break;
      }
      if (a == b) {
        int d = min(c - b, min(a, c / 2));
        t += 2 * d;
        a -= d;
        b -= d;
        c -= 2 * d;
        if (a > b) swap(a, b);
        if (b > c) swap(b, c);
        if (a > c) swap(a, c);
        continue;
      }
      if (b == c) {
        int d = b - a;
        t += d;
        b -= d;
        c -= d;
        if (a > b) swap(a, b);
        if (b > c) swap(b, c);
        if (a > c) swap(a, c);
        continue;
      }
      if (b != 0) {
        t++;
        b--;
        c--;
      }
      if (a > b) swap(a, b);
      if (b > c) swap(b, c);
      if (a > c) swap(a, c);
    }
    cout << t << '\n';
  }
  return 0;
}
int32_t main() {
  solve();
  return 0;
}

```