#include <bits/stdc++.h>
using namespace std;
inline long long rint() {
  long long x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
inline long long gcd(long long a, long long b) {
  return (b) ? gcd(b, a % b) : a;
}
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
inline long long pow(long long a, long long b, long long q) {
  long long rtn = 1;
  while (b) {
    if (b & 1) rtn = rtn * a % q;
    a = a * a % q;
    b >>= 1;
  }
  return rtn;
}
inline long long mysqrt(long long n) {
  long long x = sqrt(n);
  while (x * x < n) x++;
  while (x * x > n) x--;
  return x;
}
const long long mod = 1e9 + 7;
const long long N = 2e5 + 5;
int main() {
  int q = rint();
  while (q--) {
    int n = rint();
    int a[3];
    memset(a, 0, sizeof a);
    while (n--) {
      int x = rint();
      a[x % 3]++;
    }
    long long res = a[0];
    long long temp = min(a[1], a[2]);
    res += temp;
    a[1] -= temp;
    a[2] -= temp;
    res += a[1] / 3 + a[2] / 3;
    cout << res << "\n";
  }
}
