#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, cnt = 0;
    cin >> n;
    long long int A[n];
    for (int i = 0; i < n; i++) cin >> A[i];
    for (int i = 0; i < n; i++) {
      if (A[i] == -1) continue;
      if (A[i] % 3 == 0) {
        cnt++;
        A[i] = -1;
        continue;
      }
      for (int j = i + 1; j < n; j++)
        if (A[j] != -1 && A[j] % 3) {
          if ((A[i] + A[j]) % 3 == 0) {
            A[i] = -1;
            A[j] = -1;
            cnt++;
            break;
          }
        }
    }
    long long int c = 0;
    sort(A, A + n);
    for (int i = 0; i < n; i++)
      if (A[i] != -1) c++;
    cnt += (c / 3);
    cout << cnt << endl;
  }
}
