#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t > 0) {
    int i, j, c = 0;
    int n;
    cin >> n;
    int x;
    vector<int> v0, v1, v2;
    for (i = 0; i < n; i++) {
      cin >> x;
      if (x % 3 == 0)
        v0.push_back(x);
      else if (x % 3 == 1)
        v1.push_back(x);
      else
        v2.push_back(x);
    }
    int mn = min(v1.size(), v2.size());
    int x1 = (v1.size() - mn) / 3;
    int x2 = (v2.size() - mn) / 3;
    int sum = v0.size() + x1 + x2 + mn;
    cout << sum << endl;
    v0.clear();
    v1.clear();
    v2.clear();
    t--;
  }
  return 0;
}
