#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return a % b ? gcd(b, a % b) : b; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int prime(long long n) {
  if (n < 2) return 0;
  if (n == 2 || n == 3) return 1;
  if (n % 6 != 1 && n % 6 != 5) return 0;
  for (long long i = 5; i <= sqrt(n); i += 6) {
    if (n % i == 0 || n % (i + 2) == 0) return 0;
  }
  return 1;
}
int t, r, g, b;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> t;
  while (t--) {
    cin >> r >> g >> b;
    int mx = max(b, max(r, g));
    int ans = min((r + g + b) / 2, r + g + b - mx);
    cout << ans << endl;
  }
  return 0;
}
