#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  int ara[3];
  int a, b, c, sum, d, sum1;
  int m;
  for (int wq = 0; wq < t; wq++) {
    cin >> ara[0] >> ara[1] >> ara[2];
    sort(ara, ara + 3);
    m = ara[2];
    sum = ara[0] + ara[1] + ara[2];
    sum1 = ara[0] + ara[1];
    if (m > sum1) {
      d = sum1;
    } else {
      d = sum / 2;
    }
    cout << d << endl;
  }
  return 0;
}
