#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t > 0) {
    long long n;
    cin >> n;
    long long a = 0, b = 0, c = 0, d = 0, i = 0;
    while (i < n) {
      cin >> d;
      if (d % 3 == 0)
        a++;
      else if (d % 3 == 1)
        b++;
      else
        c++;
      i++;
    }
    d = min(c, b);
    c = abs(c - b);
    cout << a + d + c / 3 << endl;
    t--;
  }
}
