#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int r[10];
    cin >> r[0] >> r[1] >> r[2];
    sort(r, r + 3, greater<int>());
    if (r[0] >= r[1] + r[2])
      cout << r[1] + r[2] << endl;
    else
      cout << (r[0] + r[1] + r[2]) / 2 << endl;
  }
}
