#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e16 + 3;
const int mod = 1e9 + 7;
const int lim = 1e8 + 2;
int q;
long long n;
vector<long long> v;
map<long long, long long> m;
void solve() {
  cin >> q;
  while (q-- > 0) {
    m.clear();
    cin >> n;
    v.resize(n, 0);
    for (int i = 0; i < n; i++) {
      cin >> v[i];
      m[v[i] % 3]++;
    }
    long long mn = (min(m[1], m[2]));
    long long answ = m[0] + mn;
    m[1] -= mn;
    m[2] -= mn;
    cout << answ + (m[1] / 3) + (m[2] / 3) << "\n";
  }
}
void fastIO() {
  cin.sync_with_stdio(false);
  cin.tie(0);
}
void IO() {
  if (fopen("d:\\lmo.in", "r") != NULL) {
    freopen("d:\\lmo.in", "r", stdin);
  } else if (fopen("/media/Beijing/lmo.in", "r") != NULL) {
    freopen("/media/Beijing/lmo.in", "r", stdin);
  }
}
int main() {
  IO();
  fastIO();
  solve();
}
