#include <bits/stdc++.h>
inline int read() {
  int n = 0, ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    ;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + (ch ^ 48);
  return n;
}
int main() {
  int T = read();
  while (T--) {
    int ans[3] = {0, 0, 0};
    int n = read();
    while (n--) ++ans[read() % 3];
    int A = ans[0];
    if (ans[1] < ans[2])
      A += ans[1] + (ans[2] - ans[1]) / 3;
    else
      A += ans[2] + (ans[1] - ans[2]) / 3;
    printf("%d\n", A);
  }
  return 0;
}
