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