#include <bits/stdc++.h>
using namespace std;
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
inline int two(int n) { return 1 << n; }
const long long mod = 1e9 + 7;
const int maxn = 1e5 + 5;
void pre() {}
void solve();
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int TC = 1;
  cin >> TC;
  while (TC--) {
    solve();
  }
  return 0;
}
void solve() {
  int n;
  cin >> n;
  int a[n];
  int cnt[3];
  for (int i = 0; i < (3); ++i) cnt[i] = 0;
  for (int i = 0; i < (n); ++i) {
    cin >> a[i];
    cnt[a[i] % 3]++;
  }
  int ans = 0;
  ans += cnt[0];
  int min1 = min(cnt[1], cnt[2]);
  ans += min1;
  cnt[1] -= min1;
  cnt[2] -= min1;
  ans += cnt[1] / 3;
  ans += cnt[2] / 3;
  cout << ans << '\n';
}
