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