#include <bits/stdc++.h>
using namespace std;
int arr[5] = {10, 15, 60, 4, 19};
int result = 0;
int getMin(int r, int g, int b) {
  if (r < g) {
    if (r < b) {
      return r;
    } else {
      return b;
    }
  } else {
    if (g < b) {
      return g;
    } else {
      return b;
    }
  }
}
int getMax(int r, int g, int b) {
  if (r > g) {
    if (r > b) {
      return r;
    } else {
      return b;
    }
  } else {
    if (g > b) {
      return g;
    } else {
      return b;
    }
  }
}
int getMin(int a, int b) {
  if (a < b) {
    return a;
  } else {
    return b;
  }
}
void solve(int r, int g, int b) {
  int count = 0;
  int sum = r + g + b;
  int min = getMin(r, g, b);
  int max = getMax(r, g, b);
  int mid = sum - (min + max);
  result = getMin(sum / 2, min + mid);
}
void print(int arr[], int n) {
  for (int i = 0; i < n; i++) {
    printf("%d ", arr[i]);
  }
}
void merge(int a[], int l, int m, int r) {
  int n1 = m - l + 1;
  int n2 = r - m;
  int *L = new int[n1];
  int *R = new int[n2];
  for (int i = 0; i < n1; i++) {
    L[i] = arr[l + i];
  }
  for (int i = 0; i < n2; i++) {
    R[i] = arr[m + 1 + i];
  }
  int i = 0, j = 0, k = l;
  while (i < n1 && j < n2) {
    if (L[i] < R[j]) {
      arr[k] = L[i];
      k++;
      i++;
    } else {
      arr[k] = R[j];
      j++;
      k++;
    }
  }
  while (i < n1) {
    arr[k] = L[i];
    k++;
    i++;
  }
  while (j < n2) {
    arr[k] = R[j];
    k++;
    j++;
  }
}
void merge(int a[], int l, int r) {
  if (l < r) {
    int m = l + (r - l) / 2;
    merge(arr, l, m);
    merge(arr, m + 1, r);
    merge(arr, l, m, r);
  }
}
int main() {
  int n;
  int r, g, b;
  char ch;
  int min = 9999999, max = -9999999;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &r);
    if (r > max) {
      max = r;
    }
    scanf("%d", &g);
    if (g > max) {
      max = g;
    }
    scanf("%d", &b);
    if (b > max) {
      max = b;
    }
    solve(r, g, b);
    printf("%d\n", result);
  }
  return 0;
}
