//....................................<In the name of Allah>...............................//
//.................................<b_bitsmillahir Rahmanir Rahim>...................................//
// Author : Riaj Udd_bitn
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, nll_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> pii;
typedef pair<double, double> pdd;
typedef double dl;
#define lower(a, b) lower_bound((a).begin(), (a).end(), b) - (a).begin()
#define mem(a, b) memset(a, b, sizeof(a));
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define fraction(a) \
cout.unsetf(ios::floatfield); \
cout.precision(a); \
cout.setf(ios::fined, ios::floatfield);
//////////////////////////////////////////
///////////bit-manipulation///////////////
#define Mb(msk) 63 - __builtin_clzll(msk)
#define Lb(msk) __builtin_ctzll(msk)
#define ONE(msk) __builtin_popkll(msk)
#define CHECK(msk, bit) (msk & (1LL << bit))
#define ON(msk, bit) (msk | (1LL << bit))
#define Off(msk, bit) (msk & ~(1LL << bit))
#define CHANGE(msk, bit) (msk ^ (1LL << bit))
//////////////
const ll MOD = 1e9 + 7;
inline void normal(ll &a)
{
a %= MOD;
(a < 0) && (a += MOD);
}
inline ll modMul(ll a, ll b)
{
a %= MOD, b %= MOD;
normal(a), normal(b);
return (a * b) % MOD;
}
inline ll modAdd(ll a, ll b)
{
a %= MOD, b %= MOD;
normal(a), normal(b);
return (a + b) % MOD;
}
inline ll modSub(ll a, ll b)
{
a %= MOD, b %= MOD;
normal(a), normal(b);
a -= b;
normal(a);
return a;
}
inline ll modPow(ll b, ll p)
{
ll r = 1;
while (p)
{
if (p & 1)
r = modMul(r, b);
b = modMul(b, b);
p >>= 1;
}
return r;
}
inline ll modInverse(ll a) { return modPow(a, MOD - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }
// std::ofstream outputFile("C:/Users/Asus/Desktop/New folder/output.txt");
void solve()
{
ll n;
cin >> n;
vl v(n), tr(3, 0);
for (auto &a : v)
cin >> a, tr[a % 3]++;
ll ans = tr[0];
ll on = (tr[1] / 3) * 3;
ll tw = (tr[2] / 3) * 3;
ll on_tw = min(tr[1], tr[2]);
cout << ans + max({on, tw, on_tw});
cout << "\n";
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
ll t = 1;
cin >> t;
for (ll tc = 1; tc <= t; tc++)
solve();
}