#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n;
    cin >> n;
    int counter1 = 0;
    int counter2 = 0;
    int counter3 = 0;
    long* mas = new long[n];
    for (int i = 0; i < n; i++) {
      cin >> mas[i];
    }
    for (int i = 0; i < n; i++) {
      if (mas[i] % 3 == 0) {
        counter1++;
      } else if (mas[i] % 3 == 2) {
        counter2++;
      } else {
        counter3++;
      }
    }
    long res =
        counter1 + min(counter2, counter3) + abs(counter3 - counter2) / 3;
    cout << res << endl;
    delete (mas);
  }
}
