#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s[3], sum1, i, x;
  while (cin >> n) {
    for (i = 0; i < n; i++) {
      for (x = 0; x < 3; x++) {
        cin >> s[x];
      }
      sort(s, s + 3);
      if (s[1] <= s[2] - s[0]) {
        sum1 = s[0];
        s[0] = 0;
      } else {
        sum1 = s[2] - s[1];
        s[0] -= s[2] - s[1];
      }
      sum1 += s[0] / 2 * 2;
      sum1 += s[1] - s[0] / 2;
      cout << sum1 << endl;
    }
  }
}
