#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int cases;
  cin >> cases;
  for (int c = 1; c <= cases; c++) {
    int n;
    unsigned long long int ar[110];
    cin >> n;
    int count0 = 0, count1 = 0, count2 = 0;
    for (int i = 0; i < n; i++) {
      cin >> ar[i];
      ar[i] = ar[i] % 3;
      if (ar[i] == 0) {
        count0++;
      } else if (ar[i] == 1) {
        count1++;
      } else if (ar[i] == 2) {
        count2++;
      }
    }
    int sum3 = min(count2, count1);
    count0 += sum3;
    count2 -= sum3;
    count1 -= sum3;
    if (count2 == 0 && count1 == 0) {
      cout << count0 << endl;
      continue;
    } else if (count2 == 0) {
      count0 += count1 / 3;
      cout << count0 << endl;
      continue;
    } else if (count1 == 0) {
      count0 += count2 / 3;
      cout << count0 << endl;
      continue;
    }
  }
}
