#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll power(ll a, ll b){
    ll res=1;
    while(b){
        if(b&1) res=(res*a);
        a=(a*a);
        b>>=1;
    }
    return res;
}
ll powermod(ll a, ll b){
    ll res=1;
    while(b){
        if(b&1) res=(res*a)%1000000007;
        a=(a*a)%1000000007;
        b>>=1;
    }
    return res;
}
int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll n,i,ans=0;
		cin>>n;
		ll a[n];
		for(i=0;i<n;i++)
		{
			cin>>a[i];
			if(a[i]==1 || a[i]==3)
			ans++;
		}
		cout<<ans<<endl;
		
	}
}
