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