#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
map<int, int> mp;
int main() {
  int t;
  cin >> t;
  while (t--) {
    mp.clear();
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
      int x;
      cin >> x;
      if (x % 3 == 0)
        ans++;
      else
        mp[x % 3]++;
    }
    if (mp[2] == mp[1])
      ans += mp[1];
    else if (mp[2] > mp[1]) {
      ans += mp[1];
      mp[2] -= mp[1];
      ans += mp[2] / 3;
    } else if (mp[1] > mp[2]) {
      ans += mp[2];
      mp[1] -= mp[2];
      ans += mp[1] / 3;
    }
    cout << ans << endl;
  }
  return 0;
}
