#include <bits/stdc++.h>
using namespace std;
vector<char> prime(100000 + 1, true);
void sieve(long long int n) {
  prime[0] = prime[1] = false;
  for (long long int i = 2; i <= n; ++i) {
    if (prime[i]) {
      for (long long int j = 2 * i; j <= n; j += i) {
        prime[j] = false;
      }
    }
  }
}
void init(long long int ar[], long long int n, long long int val) {
  long long int i;
  for (i = 0; i < n; i++) {
    ar[i] = val;
  }
}
vector<long long int> v1;
vector<bool> visit;
vector<vector<long long int> > g;
vector<vector<long long int> > g1;
vector<long long int> ar;
vector<vector<long long int> > final;
vector<long long int> mind;
long long int c;
void dfs(long long int i, long long int n) {
  visit[i] = true;
  long long int j, k;
  for (j = 0; j < g[i].size(); j++) {
    if (!visit[g[i][j]]) {
      dfs(g[i][j], n);
    }
  }
  v1.push_back(i);
}
void dfs1(long long int i, long long int n, long long int len) {
  visit[i] = true;
  long long int j, k;
  final[len].push_back(i);
  mind[len] = min(mind[len], ar[i]);
  for (j = 0; j < g1[i].size(); j++) {
    if (!visit[g1[i][j]]) {
      dfs1(g1[i][j], n, len);
    }
  }
}
long long int search(long long int l, long long int r, long long int val,
                     long long int b[], long long int m) {
  if (r == m - 1 && b[r] < val) return -1;
  while (r - l > 1) {
    long long int mid = l + (r - l + 1) / 2;
    if (b[mid] < val) {
      l = mid;
    } else
      r = mid;
  }
  return r;
}
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int i, j, n;
    cin >> n;
    long long int ar[n];
    for (i = 0; i < n; i++) {
      cin >> ar[i];
      ar[i] = ar[i] % 3;
    }
    sort(ar, ar + n);
    long long int sum = 0;
    long long int a = 0, b = 0, c = 0;
    for (i = 0; i < n; i++) {
      if (ar[i] == 0)
        a++;
      else if (ar[i] == 1)
        b++;
      else
        c++;
    }
    sum += a;
    long long int maxs = max(b, c);
    long long int mins = min(b, c);
    sum += mins;
    maxs = maxs - mins;
    sum += maxs / 3;
    cout << sum << endl;
  }
  return 0;
}
