#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, i, j, ar[5], a, b, c, p, q, r, s, m, x, n;
  scanf("%d", &t);
  for (i = 1; i <= t; i++) {
    for (j = 0; j < 3; j++) {
      scanf("%d", &ar[j]);
    }
    c = 0;
    n = 0;
    sort(ar, ar + 3);
    p = ar[0];
    q = ar[1];
    r = ar[2];
    c += p + q;
    n += p + q + r;
    if (r > c) {
      x = c;
    } else {
      x = n / 2;
    }
    printf("%d\n", x);
  }
  return 0;
}
