#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N;
  cin >> N;
  while (N--) {
    long long int n, temp, count0 = 0, count1 = 0, count2 = 0, count = 0;
    cin >> n;
    while (n--) {
      cin >> temp;
      temp = temp % 3;
      if (temp == 0)
        count0 += 1;
      else if (temp == 1)
        count1 += 1;
      else
        count2 += 1;
    }
    count += count0;
    count += min(count1, count2);
    count += abs(count1 - count2) / 3;
    cout << count << endl;
  }
  return 0;
}
