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