#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  int a[5];
  while (t--) {
    scanf("%d", &a[1]);
    scanf("%d %d", &a[2], &a[3]);
    sort(a + 1, a + 4);
    int x = a[3] - a[2];
    int ans = min(x, a[1]);
    a[1] = a[1] - ans;
    ans = ans + a[2] + a[1] / 2;
    printf("%d\n", ans);
  }
  return 0;
}
