#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  scanf("%d", &T);
  while (T-- > 0) {
    int a[3];
    for (int i = 0; i < 3; i++) scanf("%d", &a[i]);
    sort(a, a + 3);
    int sum = a[0] + a[1] + a[2];
    int ans;
    if (a[2] > a[0] + a[1]) {
      ans = a[0] + a[1];
    } else {
      ans = sum / 2;
    }
    printf("%d\n", ans);
  }
  return 0;
}
