#include <bits/stdc++.h>
using namespace std;
long long i, j, m, n, p, q, r, a, one, two, ans;
;
map<long long, long long> mp;
int main() {
  cin >> q;
  while (q--) {
    ans = 0, one = 0, two = 0;
    cin >> n;
    for (i = 1; i <= n; i++) {
      cin >> a;
      if (a % 3 == 0)
        ans++;
      else if (a % 3 == 2)
        two++;
      else if (a % 3 == 1)
        one++;
    }
    if (one <= two) {
      ans += one;
      ans += (two - one) / 3;
    } else {
      ans += two;
      ans += (one - two) / 3;
    }
    cout << ans << "\n";
  }
}
