#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n;
    long long int x;
    int a[10] = {0};
    cin >> n;
    for (int j = 0; j < n; j++) {
      cin >> x;
      int b = x % 3;
      a[b]++;
    }
    if (a[1] > a[2]) {
      int y = a[1] - a[2];
      int z = a[0] + a[2] + y / 3;
      cout << z << endl;
    } else {
      int y = a[2] - a[1];
      int z = a[0] + a[1] + y / 3;
      cout << z << endl;
    }
  }
}
