/*
** author : meminyum
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define st first
#define nd second
#define ms(a,b) memset(a , b , sizeof a)
#define all(v) v.begin() , v.end()
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(0);
#define drop(s) cout << #s << endl
 
ll t , n;
 
int main()
{
    cin >> t;
    while(t--)
    {
        cin >> n;
        vector < ll > v(n);
        map < ll , ll > mp;
        for(ll &e : v)
        {
            cin >> e;
            ++mp[e];
        }
        cout << (mp[3] + mp[1]) << endl;
    }
}