#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  for (long long tt = 0; tt < t; tt++) {
    long long rgb[3], sum = 0;
    cin >> rgb[0] >> rgb[1] >> rgb[2];
    sort(rgb, rgb + 3);
    sum += min(rgb[2] - rgb[1] + 1, rgb[0]);
    rgb[2] -= sum;
    rgb[0] -= sum;
    rgb[1] -= (rgb[0] + 1) / 2;
    rgb[2] -= rgb[0] / 2;
    sum += rgb[0];
    sum += min(rgb[2], rgb[1]);
    cout << sum << endl;
  }
  return 0;
}
