#include <bits/stdc++.h>
using namespace std;
int main() {
  int test;
  cin >> test;
  while (test--) {
    int n, val, i, ara[3];
    cin >> n;
    memset(ara, 0, sizeof(ara));
    for (i = 0; i < n; i++) {
      cin >> val;
      ara[val % 3]++;
    }
    int ans = ara[0];
    int mn = min(ara[1], ara[2]);
    ans += mn;
    ara[1] -= mn;
    ara[2] -= mn;
    ans += (ara[1] + ara[2]) / 3;
    cout << ans << endl;
  }
}
