#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> a(n);
    vector<long long> rem(3, 0);
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
      rem[a[i] % 3]++;
    }
    long long res = rem[0];
    long long comb = min(rem[1], rem[2]);
    res += comb;
    rem[1] -= comb;
    rem[2] -= comb;
    res += rem[1] / 3;
    res += rem[2] / 3;
    cout << res << "\n";
  }
}
