#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    long long int a, num = 0, c1 = 0, c2 = 0;
    for (long long int i = 0; i < n; ++i) {
      cin >> a;
      if (a % 3 == 0)
        num++;
      else if (a % 3 == 1)
        c1++;
      else
        c2++;
    }
    num += (min(c1, c2) + max((long long int)0, abs(c1 - c2) / 3));
    cout << num << "\n";
  }
  return 0;
}
