#include <bits/stdc++.h>
using namespace std;
void solve() {
  int m1, m2, m3;
  cin >> m1 >> m2 >> m3;
  if (m1 < m2) swap(m1, m2);
  if (m1 < m3) swap(m1, m3);
  if (m2 < m3) swap(m2, m3);
  int days = 0;
  if (m1 >= m2 + m3)
    days = m2 + m3;
  else {
    days = (m1 + m2 + m3) / 2;
  }
  cout << days << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int nCases;
  cin >> nCases;
  while (nCases--) solve();
  return 0;
}
