#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, i, x, j, u, n, p, k, b, r;
  long double tmp1, tmp2;
  cin >> t;
  while (t--) {
    cin >> n;
    int a[n];
    long long c = 0, one = 0, two = 0;
    for (i = 0; i < n; i++) {
      cin >> x;
      a[i] = x % 3;
      if (a[i] == 0)
        c++;
      else if (a[i] == 1)
        one++;
      else if (a[i] == 2)
        two++;
    }
    long long small, big;
    if (one > two) {
      big = one;
      small = two;
    } else {
      big = two;
      small = one;
    }
    cout << c + small + (big - small) / 3;
    cout << "\n";
  }
  return 0;
}
