#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  int n;
  for (int i = 0; i < t; i++) {
    cin >> n;
    int ara[n];
    for (int i = 0; i < n; i++) {
      cin >> ara[i];
    }
    int req[3] = {0};
    for (int i = 0; i < n; i++) {
      req[ara[i] % 3]++;
    }
    int sum = 0;
    if (req[1] <= req[2]) {
      sum = req[0] + req[1] + (req[2] - req[1]) / 3;
    } else {
      sum = req[0] + req[2] + (req[1] - req[2]) / 3;
    }
    cout << sum << endl;
  }
}
