#include <bits/stdc++.h>
using namespace std;
long long cdiv(long long a, long long b) {
  return a / b + ((a ^ b) > 0 && a % b);
}
long long fdiv(long long a, long long b) {
  return a / b - ((a ^ b) < 0 && a % b);
}
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> v(n);
  map<long long int, long long int> mp;
  for (long long int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    v[i] = x % 3;
    mp[v[i]]++;
  }
  long long int ans = mp[0];
  long long int c = min(mp[1], mp[2]);
  ans = ans + c;
  mp[1] = mp[1] - c;
  mp[2] = mp[2] - c;
  ans = ans + mp[1] / 3 + mp[2] / 3;
  cout << ans;
  cout << endl;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
