#include <bits/stdc++.h>
#pragma optimize("O3")
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 2 * 1e9 + 7;
const int base = 2e5 + 1;
const int MAX = 1e5 + 2;
const double EPS = 1e-9;
const double PI = acos(-1.);
const int MAXN = 2 * 1e5 + 1;
int main() {
  int n;
  cin >> n;
  for (long long i = (0); i < (n); ++i) {
    int r, g, b;
    int cnt = 0;
    int a[3];
    for (long long j = (0); j < (3); ++j) cin >> a[j];
    sort(a, a + 3);
    cnt += a[0];
    int x2 = max(0, (a[2] - a[1] + a[0]) / 2);
    int x1 = max(0, a[0] - x2);
    a[1] -= x1;
    a[2] -= x2;
    a[1] = max(a[1], 0);
    a[2] = max(a[2], 0);
    cnt += min(a[1], a[2]);
    cout << cnt << '\n';
  }
  return 0;
}
