#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int w = 0; w < t; w++) {
    int ko[3];
    int i = 0;
    cin >> ko[0] >> ko[1] >> ko[2];
    sort(ko, ko + 3);
    int q = ko[2] - ko[1];
    if (q > ko[0]) {
      ko[2] -= ko[0];
      i += ko[0];
      ko[0] = 0;
    } else {
      ko[2] -= q;
      ko[0] -= q;
      i += q;
    }
    ko[1] -= ko[0] / 2;
    ko[2] -= ko[0] / 2;
    i += ko[0] / 2 * 2;
    i += ko[1];
    cout << i << endl;
  }
}
