#include <bits/stdc++.h>
int main() {
  long long int t;
  scanf("%lld", &t);
  while (t--) {
    long long int a, b, c;
    scanf("%lld %lld %lld", &a, &b, &c);
    if (a >= b && a >= c) {
      if (a >= b + c) {
        printf("%lld\n", (b + c));
      } else if (a <= b + c) {
        printf("%lld\n", (a + b + c) / 2);
      }
    } else if (b >= a && b >= c) {
      if (b >= (a + c)) {
        printf("%lld\n", (a + c));
      } else if (b <= (a + c)) {
        printf("%lld\n", (a + b + c) / 2);
      }
    } else if (c >= a && c >= b) {
      if (c >= a + b) {
        printf("%lld\n", (a + b));
      } else if (c <= (a + b)) {
        printf("%lld\n", (a + b + c) / 2);
      }
    }
  }
}
