#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int main(void) {
  int t;
  cin >> t;
  while (t--) {
    int ans = 0;
    int a[N];
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }
    sort(a, a + n);
    vector<int> vi;
    for (int i = 0; i < n; i++) {
      a[i] %= 3;
      if (a[i] != 0)
        vi.push_back(a[i]);
      else
        ans++;
    }
    if (vi.size() == 0) {
      printf("%d\n", n);
      continue;
    }
    int now_v = vi[0];
    int cnt_1 = 0;
    int cnt_2 = 0;
    if (vi[0] == 1)
      cnt_1++;
    else
      cnt_2++;
    for (int i = 1; i < vi.size(); i++) {
      if (vi[i] == 1) {
        cnt_1++;
      } else {
        cnt_2++;
      }
    }
    if (cnt_2 == 0) {
      printf("%d\n", cnt_1 / 3 + ans);
    } else if (cnt_1 == 0)
      printf("%d\n", ans + cnt_2 / 3);
    else {
      if (cnt_1 > cnt_2) {
        printf("%d\n", cnt_2 + ans + (cnt_1 - cnt_2) / 3);
      } else {
        printf("%d\n", ans + cnt_1 + (cnt_2 - cnt_1) / 3);
      }
    }
  }
  return 0;
}
