#include <bits/stdc++.h>
using namespace std;
long long n, t, i, e, n2, n3;
long long a[105], c[4];
bool b[105];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> t;
  while (t--) {
    cin >> n;
    for (i = 0; i < n; i++) {
      cin >> e;
      c[(e % 3)]++;
    }
    n2 = min(c[1], c[2]);
    c[1] = c[1] - n2;
    c[2] = c[2] - n2;
    n3 = c[1] / 3 + c[2] / 3;
    cout << c[0] + n2 + n3 << endl;
    for (i = 0; i < 3; i++) c[i] = 0;
  }
  return 0;
}
