#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    long long int t;
    cin >> t;
    long long int a = 0, b = 0, c = 0;
    for (int j = 0; j < t; ++j) {
      long long int x;
      cin >> x;
      if (x % 3 == 0) {
        a++;
      }
      if (x % 3 == 1) {
        b++;
      }
      if (x % 3 == 2) {
        c++;
      }
    }
    cout << a + min(b, c) + (b - min(b, c)) / 3 + (c - min(b, c)) / 3 << "\n";
  }
  return 0;
}
