#include <bits/stdc++.h>
using namespace std;
long long arr[500005];
int cnt[1005];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    memset(cnt, 0, sizeof(cnt));
    for (int i = 1; i <= n; i++) {
      scanf("%lld", &arr[i]);
      cnt[arr[i] % 3]++;
    }
    int ans = cnt[0];
    int a = cnt[1], b = cnt[2];
    if (a > b) swap(a, b);
    while (a + 2 <= b) {
      b -= 2;
      a++;
    }
    ans += min(a, b);
    printf("%d\n", ans);
  }
  return 0;
}
