#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    long long int arr[n], i;
    for (i = 0; i < n; i++) {
      cin >> arr[i];
      arr[i] = arr[i] % 3;
    }
    long long int ct0 = 0, ct1 = 0, ct2 = 0;
    for (i = 0; i < n; i++) {
      if (arr[i] == 0) {
        ct0++;
      }
      if (arr[i] == 1) {
        ct1++;
      }
      if (arr[i] == 2) {
        ct2++;
      }
    }
    long long int ans = ct0;
    long long int a = min(ct1, ct2);
    ct1 = ct1 - a;
    ct2 = ct2 - a;
    ans += ct1 / 3;
    ans += ct2 / 3;
    ans += a;
    cout << ans << endl;
  }
}
