#include <bits/stdc++.h>
using namespace std;
long long f(long long n, long long k) {
  long long rpta = 0;
  if (n * k < 10 && n * k > 0)
    return n * k;
  else {
    while (n > 0) {
      rpta = rpta + n % 10;
      n /= 10;
    }
    return f(rpta * k, 1);
  }
}
long long getBit(long long x, long long i) { return (x >> i) & 1LL; }
void turnOn(long long &x, long long i) { x = x | (1LL << i); }
void turnOff(long long &x, long long i) { x = x & (~(1LL << i)); }
void changeBit(long long &x, long long i) { x = x ^ (1LL << i); }
int comparar(string &a, int c, int d) {
  for (int i = 0; i + d < a.size(), i + c < a.size(); i++) {
    if (a[c + i] == a[d + i]) {
      continue;
    } else if (a[c + i] > a[d + i]) {
      return d;
    } else if (a[c + i] < a[d + i]) {
      return c;
    }
  }
  return c;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, q, k;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> q;
    long long cont = 0, c, d;
    vector<long long> a;
    vector<long long> b;
    for (long long j = 0; j < q; j++) {
      cin >> k;
      if (k % 3 == 1)
        a.push_back(k);
      else if (k % 3 == 2)
        b.push_back(k);
      else
        cont++;
    }
    cont = cont + min(a.size(), b.size());
    c = a.size() - min(a.size(), b.size());
    d = b.size() - min(a.size(), b.size());
    cont = cont + c / 3 + d / 3;
    cout << cont << endl;
  }
}
