#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long T;
  cin >> T;
  for (long long t = 0; t < (long long)T; t++) {
    long long n;
    cin >> n;
    vector<long long> cnt(3, 0);
    for (long long i = 0; i < (long long)n; i++) {
      long long num;
      cin >> num;
      cnt[num % 3]++;
    }
    long long mini = min(cnt[1], cnt[2]);
    long long ans = cnt[0] + mini;
    if (cnt[1] > cnt[2]) {
      cnt[1] -= cnt[2];
      ans += cnt[1] / 3;
    } else {
      cnt[2] -= cnt[1];
      ans += cnt[2] / 3;
    }
    cout << ans << endl;
  }
  return 0;
}
