#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  for (; t; t--) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<int> gist(3);
    for (int i = 0; i < n; i++) gist[a[i] % 3]++;
    while (gist[1] > 0 && gist[2] > 0) {
      gist[1]--;
      gist[2]--;
      gist[0]++;
    }
    while (gist[1] - 3 >= 0) {
      gist[1] -= 3;
      gist[0]++;
    }
    while (gist[2] - 3 >= 0) {
      gist[2] -= 3;
      gist[0]++;
    }
    cout << gist[0] << "\n";
  }
  return 0;
}
