#include <bits/stdc++.h>
using namespace std;
const long long mxn = 105;
const long long mxm = 1;
const long long INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const double eps = 1e-7;
long long a[mxn];
signed main(void) {
  long long q;
  cin >> q;
  while (q--) {
    long long n;
    cin >> n;
    long long ct1 = 0, ct2 = 0, ct0 = 0, ans = 0;
    for (long long i = 1; i <= n; i++) {
      cin >> a[i];
      a[i] = a[i] % 3;
      if (a[i] == 1) ct1++;
      if (a[i] == 2) ct2++;
      if (a[i] == 0) ct0++;
    }
    ans = ct0;
    if (ct1 >= ct2) {
      ans += ct2;
      ct1 -= ct2;
      ans += ct1 / 3;
    } else {
      ans += ct1;
      ct2 -= ct1;
      ans += ct2 / 3;
    }
    cout << ans << endl;
  }
  return 0;
}
