#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long n, m, q;
  cin >> q;
  while (q--) {
    cin >> n;
    long long a = 0ll, b = 0ll, c = 0ll;
    for (long long i = 1ll; i <= n; i++) {
      cin >> m;
      if (m % 3ll == 0ll) c++;
      if (m % 3ll == 2ll) b++;
      if (m % 3ll == 1ll) a++;
    }
    long long x = min(b, a);
    b -= x;
    a -= x;
    c += x;
    c += (a / 3ll);
    c += (b / 3ll);
    cout << c << endl;
  }
}
