#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int ans = 0, sum = 0, a[7];
    for (int j = 0; j < 3; j++) {
      cin >> a[j];
      sum += a[j];
    }
    sort(a, a + 3);
    if (a[0] + a[1] <= a[2])
      ans += a[0] + a[1];
    else
      ans += sum / 2;
    cout << ans << '\n';
  }
}
