#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
}
const int N = 2e5 + 2;
int p[N], id[27];
int find(int v) {
  if (p[v] == v) return v;
  return p[v] = find(p[v]);
}
int main() {
  fast();
  int t;
  cin >> t;
  while (t--) {
    long long int r, g, b;
    cin >> r >> g >> b;
    long long int temp = r, sum = r + g + b;
    r = min(r, min(g, b));
    b = max(temp, max(g, b));
    g = sum - (r + b);
    if (r + g <= b)
      cout << r + g << endl;
    else
      cout << (long long int)(sum / 2) << endl;
  }
  return 0;
}
