#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ff first
# define ss second
# define MOD 1000000007
#define MAXN 200007
ll arr[MAXN];
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
     
}
ll power(ll base, ll exp)
{
    ll ans = 1;
    while (exp)
    {
        if (exp & 1)
            ans = (ans * base) % MOD;
        base = (base * base) % MOD;
        exp >>= 1;
    }
 
    return ans;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    cin >> t;
    while (t-->0)
	{
		int n;
		cin>>n;
		int arr[4]={0};
		for(int i=0;i<n;i++)
		{
			int temp;
			cin>>temp;
			arr[temp]++;
		}
		cout<<arr[1]+arr[3]<<endl;
    }
    return 0;
}