#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    std::vector<int> vc(3);
    for (int i = 0; i < n; i++) {
      int a;
      cin >> a;
      vc[a % 3]++;
    }
    int x = vc[0];
    int y = vc[1];
    int z = vc[2];
    int ct = 0;
    ct += x;
    int zy = min(y, z);
    ct += zy;
    y = y - zy;
    z = z - zy;
    ct += (y / 3);
    ct += (z / 3);
    cout << ct << endl;
  }
  return 0;
}
