#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  long long tc;
  cin >> tc;
  while (tc--) {
    vector<long long> a(3);
    for (int i = 0; i < 3; i++) {
      cin >> a[i];
    }
    sort(begin(a), end(a));
    if (a[0] + a[1] >= a[2]) {
      cout << (a[0] + a[1] + a[2]) / 2 << "\n";
    } else {
      cout << a[0] + a[1] << "\n";
    }
  }
}
