#include <bits/stdc++.h>
using namespace std;
int a[200010] = {0}, vis[200010] = {0}, ans[200010] = {0};
int dfs(int x, int d) {
  vis[x] = 1;
  if (vis[a[x]]) return ans[x] = d;
  return ans[x] = dfs(a[x], d + 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long int q;
  cin >> q;
  while (q--) {
    long long int a, b, c;
    cin >> a >> b >> c;
    cout << min((a + b + c) / 2, a + b + c - max(a, max(b, c))) << "\n";
  }
  return 0;
}
