#include <bits/stdc++.h>
using namespace std;
const int N = 300 * 1000 + 10;
const long long MOD = 1000000007;
const long long INF = 10000000000;
long long n;
int t;
int a[3], b;
int main(void) {
  cin >> t;
  for (int i = 0; i < t; ++i) {
    cin >> n;
    for (int i = 0; i < 3; ++i) {
      a[i] = 0;
    }
    for (int i = 0; i < n; ++i) {
      cin >> b;
      a[b % 3]++;
    }
    cout << a[0] + min(a[1], a[2]) + (max(a[1], a[2]) - min(a[1], a[2])) / 3
         << endl;
  }
  return 0;
}
