#include <bits/stdc++.h>
using namespace std;
int t;
int A[3];
int main() {
  scanf("%d", &t);
  int ans = 0, n;
  long long a;
  while (t--) {
    A[0] = A[1] = A[2] = 0;
    ans = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
      scanf("%I64d", &a);
      A[a % 3]++;
    }
    ans += A[0];
    int x = min(A[1], A[2]);
    ans += x;
    A[1] -= x;
    A[2] -= x;
    ans += A[1] / 3 + A[2] / 3;
    cout << ans << '\n';
  }
}
