#include <bits/stdc++.h>
using namespace std;
int x[3], T;
int main() {
  cin >> T;
  while (T--) {
    for (int i = 0; i < 3; i++) {
      cin >> x[i];
    }
    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;
}
