#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int t, n, x;
  int c0, c1, c2;
  cin >> t;
  while (t--) {
    cin >> n;
    c0 = 0, c1 = 0, c2 = 0;
    for (int i = 0; i < n; i++) {
      cin >> x;
      if (x % 3 == 0) c0++;
      if (x % 3 == 1) c1++;
      if (x % 3 == 2) c2++;
    }
    int ans = c0 + min(c1, c2) + abs(c1 - c2) / 3;
    cout << ans << "\n";
  }
  return 0;
}
