#include <bits/stdc++.h>
using namespace std;
int a[3] = {0};
int main() {
  int T, N;
  cin >> T;
  int ans, minx, maxx;
  for (int t = 0; t < T; t++) {
    cin >> N;
    a[0] = 0;
    a[1] = 0;
    a[2] = 0;
    for (int i = 0; i < N; i++) {
      int in;
      cin >> in;
      a[in % 3]++;
    }
    ans = 0;
    ans += a[0];
    minx = min(a[1], a[2]);
    maxx = max(a[1], a[2]);
    ans += minx;
    ans += (maxx - minx) / 3;
    cout << ans << endl;
  }
}
