#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, k, ans = 0, cnt1 = 0, cnt2 = 0;
  cin >> n;
  for (long long i = (0); i < (n); i++) {
    cin >> k;
    if (k % 3 == 0)
      ans++;
    else if (k % 3 == 1)
      cnt1++;
    else
      cnt2++;
  }
  k = min(cnt1, cnt2);
  ans += k;
  cnt1 -= k;
  cnt2 -= k;
  ans += cnt1 / 3 + cnt2 / 3;
  cout << ans << "\n";
}
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
