#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
const double EPS = 1e-9;
const int mod = 1e9 + 7;
inline void File() {}
int dr[4] = {1, -1, 0, 0};
int dc[4] = {0, 0, 1, -1};
void myMain() {
  int n;
  cin >> n;
  vector<int> arr(n);
  for (int &it : arr) cin >> it;
  int ans = 0, two = 0, one = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] % 3 == 0) ans++;
    if (arr[i] % 3 == 1) one++;
    if (arr[i] % 3 == 2) two++;
  }
  int mn = min(two, one);
  one -= mn, two -= mn, ans += mn;
  cout << ans + two / 3 + one / 3 << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  File();
  int t = 1;
  cin >> t;
  while (t--) {
    myMain();
  }
}
