#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 1; i <= t; i++) {
    int n;
    cin >> n;
    vector<int> a;
    for (int j = 0; j < n; j++) {
      int m;
      cin >> m;
      a.push_back(m);
    }
    int cnt1 = 0, cnt2 = 0, cnt3 = 0;
    for (int b = 0; b < n; b++) {
      if (a[b] % 3 == 0) {
        cnt3++;
      }
      if (a[b] % 3 == 1) {
        cnt1++;
      }
      if (a[b] % 3 == 2) {
        cnt2++;
      }
    }
    int x = 0;
    if (cnt1 > cnt2) {
      x = cnt3 + cnt2 + (cnt1 - cnt2) / 3;
    } else {
      x = cnt3 + cnt1 + (cnt2 - cnt1) / 3;
    }
    cout << x << endl;
  }
  return 0;
}
