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