#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  int a[3];
  while (t--) {
    memset(a, 0, sizeof(a));
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
      int in;
      cin >> in;
      a[in % 3]++;
    }
    if (a[2] >= a[1]) {
      cout << a[0] + a[1] + ((a[2] - a[1]) / 3) << endl;
    } else {
      cout << a[0] + a[2] + ((a[1] - a[2]) / 3) << endl;
    }
  }
  return 0;
}
