#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  long long T;
  cin >> T;
  while (T--) {
    long long n;
    cin >> n;
    long long ans = 0;
    long long one = 0, two = 0;
    for (int i = 1; i <= n; i++) {
      long long x;
      cin >> x;
      x %= 3;
      if (x == 0) ans++;
      if (x == 1) one++;
      if (x == 2) two++;
    }
    if (one >= two) {
      ans += two;
      ans += (one - two) / 3;
    } else {
      ans += one;
      ans += (two - one) / 3;
    }
    cout << ans << "\n";
  }
  return 0;
}
