#include <bits/stdc++.h>
using namespace std;
long long v[5];
int main() {
  int q;
  cin >> q;
  for (int i = 1; i <= q; i++) {
    for (int j = 1; j <= 3; j++) cin >> v[j];
    sort(v + 1, v + 4);
    long long rasp = min(v[1] + v[2], v[3]);
    v[3] -= (v[2] - v[1]);
    rasp = max(rasp, v[2] + v[3] / 2);
    cout << rasp << "\n";
  }
  return 0;
}
