#include <bits/stdc++.h>
using namespace std;
int min(int a, int b) {
  if (a > b) {
    return b;
  }
  return a;
}
int main() {
  int t;
  int answer[3];
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    answer[0] = 0;
    answer[1] = 0;
    answer[2] = 0;
    while (n--) {
      int a;
      cin >> a;
      answer[a % 3]++;
    }
    int getMin = min(answer[1], answer[2]);
    cout << answer[0] + getMin + int((answer[1] - getMin) / 3) +
                int((answer[2] - getMin) / 3)
         << endl;
  }
  return 0;
}
