#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b, c;
    cin >> a >> b >> c;
    int m = max(c, max(a, b));
    cout << min((a + b + c) / 2, a + b + c - m) << endl;
  }
  return 0;
}
