#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
int dx4[] = {+1, -1, +0, +0};
int dy4[] = {+0, +0, +1, -1};
int dx8[] = {+0, +0, +1, -1, -1, +1, -1, +1};
int dy8[] = {-1, +1, +0, +0, +1, +1, -1, -1};
int dr[] = {-1, 1, -2, -2, -1, 1, 2, 2};
int dc[] = {-2, -2, -1, 1, 2, 2, 1, -1};
int main() {
  int tc;
  cin >> tc;
  while (tc--) {
    int n;
    cin >> n;
    vector<int> rem(3, 0);
    int a, div3 = 0;
    for (int i = 0; i < (int)(n); ++i) {
      cin >> a;
      a % 3 != 0 ? rem[a % 3]++ : div3++;
    }
    int extra = min(rem[1], rem[2]);
    div3 += extra;
    rem[1] -= extra;
    rem[2] -= extra;
    div3 += rem[1] / 3;
    div3 += rem[2] / 3;
    cout << div3 << '\n';
  }
  return 0;
}
