#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t > 0) {
    long long int n, i, twos = 0, ones = 0, count = 0;
    cin >> n;
    long long int a[n];
    for (i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (i = 0; i < n; i++) {
      if (a[i] % 3 == 0)
        count++;
      else if (a[i] % 3 == 1)
        ones++;
      else if (a[i] % 3 == 2)
        twos++;
    }
    count += ones > twos ? twos : ones;
    if (ones > twos) {
      ones -= twos;
      count += ones / 3;
    } else if (ones < twos) {
      twos -= ones;
      count += twos / 3;
    }
    cout << count << endl;
    t--;
  }
}
