#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int Min(int a, int b) {
  if (a < b) return a;
  return b;
}
int Max(int a, int b) { return a + b - Min(a, b); }
int L[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t, n, i, r, g, b;
  cin >> t;
  while (t > 0) {
    cin >> r >> g >> b;
    int rj = 0;
    int temp;
    if (g >= r) {
      temp = g;
      g = r;
      r = temp;
    }
    if (b >= r) {
      temp = b;
      b = r;
      r = temp;
    }
    if (r >= g && r >= b) {
      if (g >= b) {
        rj += b;
        b -= r - g;
        b = Max(b, 0);
        r = g;
        if (b % 2 == 0) {
          r -= b / 2;
          g -= b / 2;
        } else {
          r -= b / 2 + 1;
          g -= b / 2;
        }
        rj += Min(r, g);
      } else {
        rj += g;
        g -= r - b;
        g = Max(g, 0);
        r = b;
        if (g % 2 == 0) {
          r -= g / 2;
          b -= g / 2;
        } else {
          r -= g / 2 + 1;
          b -= g / 2;
        }
        rj += Min(r, b);
      }
    }
    cout << rj << endl;
    t -= 1;
  }
  return 0;
}
