#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int _ = 0; _ < t; _++) {
    vector<int> c(3);
    for (int i = 0; i < 3; i++) cin >> c[i];
    sort(c.begin(), c.end());
    int ans = 0;
    if (c[2] > c[0] + c[1])
      ans = c[0] + c[1];
    else
      ans = ((c[0] + c[1] + c[2]) / 2);
    cout << ans << "\n";
  }
}
