#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int MOD = 1000000007;
const int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
signed main() {
  cin.tie(0), cout.tie(0);
  ios::sync_with_stdio(0);
  int q;
  cin >> q;
  while (q--) {
    vector<int> v(3);
    cin >> v[0];
    cin >> v[1];
    cin >> v[2];
    sort(v.begin(), v.end());
    int res = v[0];
    if (v[2] - v[1] >= v[0])
      v[2] -= v[0];
    else {
      int diff = v[0] - (v[2] - v[1]);
      v[2] = v[1];
      v[1] -= diff / 2;
      v[2] -= diff / 2 + (diff % 2);
    }
    res += min(v[1], v[2]);
    cout << res << "\n";
  }
  return 0;
}
