#include <bits/stdc++.h>
using namespace std;
int ara[105];
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    int twos = 0, ones = 0, zeros = 0;
    for (int i = 0; i < n; i++) {
      cin >> ara[i];
      ara[i] %= 3;
      if (ara[i] == 2)
        twos++;
      else if (ara[i] == 1)
        ones++;
      else
        zeros++;
    }
    int d = min(ones, twos);
    zeros += d;
    ones -= d;
    twos -= d;
    zeros += (ones / 3) + (twos / 3);
    cout << zeros << endl;
  }
}
