#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, n, ar[100010];
  long long int xr[50010], yr[50010], mr[50010];
  while (cin >> t) {
    for (int i = 0; i < t; i++) {
      cin >> n;
      xr[i] = 0;
      yr[i] = 0;
      mr[i] = 0;
      for (int j = 0; j < n; j++) {
        cin >> ar[j];
        if (ar[j] % 3 == 1) xr[i]++;
        if (ar[j] % 3 == 2) yr[i]++;
        if (ar[j] % 3 == 0 && ar[j] != 0) mr[i]++;
      }
    }
    for (int i = 0; i < t; i++) {
      if (xr[i] >= yr[i])
        cout << yr[i] + mr[i] + (xr[i] - yr[i] - (xr[i] - yr[i]) % 3) / 3
             << endl;
      else
        cout << mr[i] + xr[i] + (yr[i] - xr[i] - (yr[i] - xr[i]) % 3) / 3
             << endl;
    }
  }
}
