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