#include <bits/stdc++.h>
using namespace std;
long long t, k;
long long m[4];
int main() {
  cin >> t;
  for (int i = 1; i <= t; i++) {
    k = 0;
    cin >> m[1] >> m[2] >> m[3];
    sort(m + 1, m + 4);
    if (m[3] == m[2]) {
      k = m[2] + m[1] / 2;
    } else if (m[3] - m[2] <= m[1]) {
      m[1] -= m[3] - m[2];
      k = m[3] + m[1] / 2;
    } else {
      k = min(m[3], m[1] + m[2]);
    }
    cout << k << endl;
  }
}
