#include <bits/stdc++.h>
using namespace std;
int arr[3];
int t, n;
vector<int> ans;
int main() {
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    scanf("%d", &n);
    int temp = 0;
    for (int j = 0; j < n; j++) {
      int inp;
      scanf("%d", &inp);
      arr[inp % 3]++;
    }
    temp += arr[0];
    int tmp2 = min(arr[1], arr[2]);
    temp += tmp2;
    arr[1] -= tmp2;
    arr[2] -= tmp2;
    temp += (arr[1] / 3);
    temp += (arr[2] / 3);
    ans.push_back(temp);
    arr[0] = 0;
    arr[1] = 0;
    arr[2] = 0;
  }
  for (int i = 0; i < t; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}
