#include <bits/stdc++.h>
const long long MOD = 1000 * 1000 * 1000 + 7;
const long long MOD1 = 998244353;
const long long INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
using namespace std;
long long power(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = (long long)(res * x);
    y = y >> 1;
    if (x <= 100000000) x = (long long)(x * x);
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long T;
  cin >> T;
  while (T--) {
    long long n;
    cin >> n;
    long long cnt[3] = {0};
    long long x;
    for (int(i) = (0); (i) < (n); ++(i)) {
      cin >> x;
      cnt[x % 3] += 1;
    }
    long long ans = cnt[0] + min(cnt[1], cnt[2]);
    long long s = min(cnt[1], cnt[2]);
    cnt[1] -= s;
    cnt[2] -= s;
    ans += (cnt[1] / 3) + (cnt[2] / 3);
    cout << ans << "\n";
  }
  return 0;
}
