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