#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, n, ans;
  long long f;
  cin >> t;
  while (t--) {
    cin >> n;
    long long q[n];
    long long w[3] = {0};
    ans = 0;
    for (long long i = 0; i < n; i++) {
      cin >> q[i];
      q[i] %= 3;
      w[q[i]]++;
    }
    ans = w[0];
    f = min(w[1], w[2]);
    ans += f;
    w[1] -= f;
    w[2] -= f;
    ans += w[1] / 3 + w[2] / 3;
    cout << ans << endl;
  }
  return 0;
}
