#include <bits/stdc++.h>
using namespace std;
int N, T, M, K;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  vector<int> V(3);
  cin >> T;
  for (int(_) = 0; (_) < (T); (_)++) {
    cin >> V[0] >> V[1] >> V[2];
    sort(V.begin(), V.end());
    if (V[0] + V[1] <= V[2])
      cout << V[0] + V[1] << endl;
    else
      cout << (V[0] + V[1] + V[2]) / 2 << endl;
  }
  return 0;
}
