#include <bits/stdc++.h>
using namespace std;
void AajFirMinusHogaBC() {
  int n;
  cin >> n;
  int ar[n];
  std::map<int, int> map;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
    if (ar[i] % 3 == 0) {
      map[1]++;
    } else if (ar[i] % 3 == 1) {
      map[2]++;
    } else {
      map[3]++;
    }
  }
  cout << map[1] + min(map[2], map[3]) + (map[2] - min(map[2], map[3])) / 3 +
              (map[3] - min(map[2], map[3])) / 3;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tt = 1;
  cin >> tt;
  for (int _ = 0; _ < tt; _++) {
    AajFirMinusHogaBC();
    cout << endl;
  }
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
