#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 107;
int nTest;
int n;
int x;
int cnt[3];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> nTest;
  for (int t = 1; t <= nTest; ++t) {
    cin >> n;
    long long sum = 0;
    fill(cnt, cnt + 3, 0);
    for (int i = 1; i <= n; ++i) {
      cin >> x;
      cnt[x % 3]++;
    }
    if (cnt[1] >= cnt[2]) {
      sum += cnt[2];
      cnt[1] -= cnt[2];
      sum += cnt[1] / 3;
    } else {
      sum += cnt[1];
      cnt[2] -= cnt[1];
      sum += cnt[2] / 3;
    }
    sum += cnt[0];
    cout << sum << "\n";
  }
  return 0;
}
