#include <bits/stdc++.h>
using namespace std;
int t, n;
const int N = 110;
int main() {
  cin >> t;
  while (t--) {
    cin >> n;
    int count[3] = {0};
    for (int i = 0; i < n; i++) {
      int t;
      cin >> t;
      count[t %= 3]++;
    }
    int ans = 0;
    ans += count[0];
    if (count[2] > count[1]) {
      ans += count[1];
      ans += (count[2] - count[1]) / 3;
    } else {
      ans += count[2];
      ans += (count[1] - count[2]) / 3;
    }
    printf("%d\n", ans);
  }
  return 0;
}
