#include <bits/stdc++.h>
using namespace std;
const long long N = 1e2 + 7;
void solve() {
  int a[5], cnt = 0;
  cin >> a[1] >> a[2] >> a[3];
  sort(a + 1, a + 4);
  if (a[2] == a[3] && a[1] != a[2]) {
    cnt += a[1];
    a[2] -= a[1] / 2;
    a[3] -= a[1] / 2;
    if (a[1] % 2) {
      a[3]--;
    }
  } else {
    int x = min(a[3] - a[2], a[1]);
    a[1] -= x;
    a[3] -= x;
    cnt += x;
    a[3] -= a[1] / 2;
    a[2] -= a[1] / 2;
    cnt += a[1];
    if (a[1] % 2 && a[3] > 0) {
      a[3]--;
    }
  }
  cnt += min(a[2], a[3]);
  cout << cnt << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T = 1;
  cin >> T;
  while (T--) solve();
}
