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