#include <bits/stdc++.h>
const long long max9 = 10 + 1e9, max6 = 10 + 1e6, max12 = 10 + 1e12,
                max15 = 10 + 1e15;
const long long min6 = -1 * max6, min9 = -1 * max9, min12 = -1 * max12,
                min15 = -1 * max15;
const long long R = 7 + 1e9, NN = 10 + 1e5;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[3];
    memset(a, 0, sizeof(a));
    for (int i = (0); i < (n); ++i) {
      int x;
      cin >> x;
      a[x % 3]++;
    }
    int ans = a[0];
    if (a[2] <= a[1]) {
      a[1] -= a[2];
      ans += a[2];
      a[2] = 0;
    }
    if (a[2] >= a[1]) {
      a[2] -= a[1];
      ans += a[1];
      a[1] = 0;
    }
    ans += a[2] / 3;
    ans += a[1] / 3;
    cout << ans << endl;
  }
  return 0;
}
