#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    int ans = 0;
    int cnt1, cnt2;
    cnt1 = cnt2 = 0;
    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      if (x % 3 == 0) ans++;
      if (x % 3 == 1) cnt1++;
      if (x % 3 == 2) cnt2++;
    }
    int m = min(cnt1, cnt2);
    ans += m;
    cnt1 -= m;
    cnt2 -= m;
    if (cnt2 == 0)
      ans += cnt1 / 3;
    else
      ans += cnt2 / 3;
    cout << ans << endl;
  }
  return 0;
}
