#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a;
    int rem1 = 0;
    int rem2 = 0;
    int rem0 = 0;
    for (int i = 0; i < n; i++) {
      cin >> a;
      if (a % 3 == 1) {
        rem1++;
      } else if (a % 3 == 2) {
        rem2++;
      } else {
        rem0++;
      }
    }
    long minrem = min(rem2, rem1);
    long maxrem = max(rem2, rem1);
    cout << (rem0 + minrem + (abs(maxrem - minrem) / 3)) << endl;
  }
  return 0;
}
