#include <bits/stdc++.h>
using namespace std;
const long long INF = 4e18;
const int MAX = 2e5 + 5;
const long long mod = 998244353;
long long t, n, cnt[5], a[MAX];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 0; i < 3; ++i) cnt[i] = 0;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      ++cnt[a[i] % 3];
    }
    cout << cnt[0] + min(cnt[1], cnt[2]) + (cnt[1] - min(cnt[1], cnt[2])) / 3 +
                (cnt[2] - min(cnt[1], cnt[2])) / 3
         << '\n';
  }
  return 0;
}
