#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long ts;
  cin >> ts;
  while (ts--) {
    long long tot = 0, rs = 0, a, b, c;
    cin >> a >> b >> c;
    long long baki = (a + b + c) - max(a, max(b, c));
    long long maxx = max(a, max(b, c));
    rs = min(maxx, baki);
    baki -= rs;
    rs += (baki / 2);
    cout << rs << endl;
  }
}
