#include <bits/stdc++.h>
using namespace std;
int cnt[105];
int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    int n;
    scanf("%d", &n);
    int t;
    memset(cnt, 0, sizeof(cnt));
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &t);
      cnt[t % 3]++;
    }
    cout << cnt[0] + min(cnt[1], cnt[2]) + abs(cnt[1] - cnt[2]) / 3 << endl;
  }
  return 0;
}
