#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n, i, p;
    cin >> n;
    long long cnt1 = 0, cnt2 = 0, cnt3 = 0, ans = 0;
    for (i = 0; i < n; i++) {
      cin >> p;
      if (p % 3 == 0)
        cnt3++;
      else if (p % 3 == 1)
        cnt1++;
      else
        cnt2++;
    }
    cout << min(cnt1, cnt2) + cnt3 + ((max(cnt1, cnt2) - min(cnt1, cnt2)) / 3)
         << endl;
  }
}
