#include <bits/stdc++.h>
using namespace std;
const int maxn = 10009;
int main() {
  int a[maxn];
  int t;
  cin >> t;
  int sum[maxn];
  memset(sum, 0, sizeof(sum));
  int e = 0;
  while (t--) {
    memset(a, 0, sizeof(a));
    for (int i = 0; i < 3; i++) {
      cin >> a[i];
    }
    sort(a, a + 3);
    sum[e] = a[0];
    int x, y;
    if (a[1] == a[2]) {
      if (a[0] % 2 == 0) {
        x = y = a[0] / 2;
      } else {
        x = a[0] / 2;
        y = a[0] / 2 + 1;
      }
      a[1] = a[1] - x;
      a[2] = a[2] - y;
    } else {
      x = a[2] - a[1];
      if (x > a[0]) {
        a[2] = a[2] - a[0];
      } else {
        a[2] = a[2] - x;
        a[0] = a[0] - x;
        if (a[0] % 2 == 0) {
          x = y = a[0] / 2;
        } else {
          x = a[0] / 2;
          y = a[0] / 2 + 1;
        }
        a[1] = a[1] - x;
        a[2] = a[2] - y;
      }
    }
    if (a[1] > a[2]) {
      swap(a[1], a[2]);
    }
    sum[e] += a[1];
    e++;
  }
  for (int i = 0; i < e; i++) {
    cout << sum[i] << endl;
  }
  return 0;
}
