#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, x;
  cin >> t;
  while (t--) {
    cin >> n;
    int c[3] = {0};
    while (n--) {
      cin >> x;
      c[x % 3]++;
    }
    if (c[1] > c[2])
      c[0] += (c[2] + (c[1] - c[2]) / 3);
    else
      c[0] += (c[1] + (c[2] - c[1]) / 3);
    cout << c[0] << endl;
  }
}
