#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll t, i, j, a, b, c, x, y, n, cnt = 0, ans = 0;
  cin >> t;
  while (t--) {
    cnt = 0;
    vector<ll> v;
    cin >> a >> b >> c;
    v.push_back(a), v.push_back(b), v.push_back(c);
    sort(v.rbegin(), v.rend());
    if (v[0] >= v[1] + v[2])
      cout << v[1] + v[2] << endl;
    else
      cout << (v[0] + v[1] + v[2]) / 2 << endl;
  }
  return 0;
}
