#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(10);
  cout.tie(nullptr);
  cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    int ar[5];
    cin >> ar[0] >> ar[1] >> ar[2];
    sort(ar, ar + 3);
    int res = 0;
    int x = ar[2] - ar[1];
    x = min(x, ar[0]);
    res += x;
    ar[0] -= x;
    ar[2] -= x;
    if (ar[0] == 0)
      res += ar[1];
    else {
      int nibo = ar[0] / 2;
      ar[1] -= nibo;
      ar[2] -= nibo;
      res += 2 * nibo;
      ar[0] -= 2 * nibo;
      res += ar[1];
    }
    cout << res << endl;
  }
  return 0;
}
