#include <bits/stdc++.h>
using namespace std;
constexpr long long int MOD = 1000000007;
constexpr double EPS = 1e-8;
long long int N, M, K, H, W, L, R;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> K;
  while (K--) {
    cin >> N;
    vector<int> box(3);
    for (int i = 0; i < N; i++) {
      cin >> M;
      box[M % 3]++;
    }
    cout << box[0] + min(box[2], box[1]) + abs(box[1] - box[2]) / 3 << endl;
  }
}
