#include <bits/stdc++.h>
using namespace std;
int t, n, a, i, j, x, y, z, p, mx, mn, s;
int main() {
  cin >> t;
  for (i = 1; i <= t; i++) {
    cin >> n;
    x = 0;
    y = 0;
    z = 0;
    for (j = 1; j <= n; j++) {
      cin >> a;
      if (a % 3 == 0)
        x = x + 1;
      else if (a % 3 == 1)
        y = y + 1;
      else if (a % 3 == 2)
        z = z + 1;
    }
    if (z <= y) {
      mx = y;
      mn = z;
    } else {
      mx = z;
      mn = y;
    }
    p = mx - mn;
    s = x + mn + p / 3;
    cout << s << '\n';
  }
  return 0;
}
