#include <bits/stdc++.h>
int a[3];
int counts = 0;
int main() {
  int n;
  scanf("%d", &n);
  while (n--) {
    int m;
    a[0] = 0;
    a[1] = 0;
    a[2] = 0;
    scanf("%d", &m);
    for (int i = 0; i < m; i++) {
      int x;
      scanf("%d", &x);
      x = x % 3;
      a[x]++;
    }
    int res = 0;
    if (a[1] > a[2]) {
      res = a[0] + a[2] + (a[1] - a[2]) / 3;
    } else {
      res = a[0] + a[1] + (a[2] - a[1]) / 3;
    }
    printf("%d\n", res);
  }
}
