#include <bits/stdc++.h>
using namespace std;
long long int MODULO = 1e9 + 7;
bool myAssert(bool b);
void testDrivenDevelopment();
int start(int argc = 0, char const *argv[] = NULL);
vector<int> *g;
bool *isvisited;
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int res, q, n, m, d[3];
  long long int a;
  cin >> q;
  while (q--) {
    d[0] = 0;
    d[1] = 0;
    d[2] = 0;
    res = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> a;
      m = (int)(a % 3);
      d[m]++;
    }
    if (d[1] > d[2]) {
      swap(d[1], d[2]);
    }
    res = d[0] + d[1] + (d[2] - d[1]) / 3;
    cout << res << "\n";
  }
  return 0;
}
