#include <bits/stdc++.h>
using namespace std;
const long long MAXN = (long long)1e5 + 10;
vector<long long> G[MAXN];
vector<long long> v;
vector<int> vec;
long long b, x = 0, t = 0, y, m, n, sum, k = 0, flag = 0, ans = 0;
string s;
void f() {
  sum = 0;
  y = 0;
  m = 0;
  k = 0;
  for (int i = 0; i < v.size(); i++) {
    if (v[i] % 3 == 2) y++;
    if (v[i] % 3 == 1) m++;
    if (v[i] % 3 == 0) k++;
  }
  t = min(y, m);
  sum = max(y, m) - min(y, m);
  sum /= 3;
  vec.push_back(t + k + sum);
  v.clear();
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    for (int j = 0; j < x; j++) {
      cin >> b;
      v.push_back(b);
    }
    f();
  }
  for (int i = 0; i < vec.size(); i++) {
    cout << vec[i] << endl;
  }
  return 0;
}
