#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q;
  cin >> q;
  long long int n;
  while (q--) {
    cin >> n;
    int a[n];
    int count1 = 0;
    int count2 = 0;
    int count3 = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] % 3 == 0) count3++;
      if (a[i] % 3 == 1) count1++;
      if (a[i] % 3 == 2) count2++;
    }
    int sum;
    if (count1 > count2) {
      sum = count3 + count2;
      int d = (count1 - count2) / 3;
      sum += d;
    } else {
      sum = count3 + count1;
      int d = (count2 - count1) / 3;
      sum += d;
    }
    cout << sum << endl;
  }
  return (0);
}
