#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long N = 1e5 + 5;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t, a, b, c;
  cin >> t;
  while (t--) {
    long long ar[3];
    cin >> ar[0] >> ar[1] >> ar[2];
    sort(ar, ar + 3);
    a = ar[0];
    b = ar[1];
    c = ar[2];
    if (c >= (a + b))
      cout << a + b << "\n";
    else {
      long long x = (a + b - c) / 2;
      long long y = c;
      cout << x + y << "\n";
    }
  }
}
