#include <bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end() 
#define int long long int
#define double long double
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define mxn 100005
#define vi vector<int>
#define pb push_back
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define output(x) cout << ( x ? "YES" : "NO" ) << '\n' ;
using namespace std;
void solve()
{
    int n;
    cin>>n;
    int ans=0;
    for(int i=0;i<n;i++){
        int j;
        cin>>j;
        if(j==1 || j==3) ans++;
    }
    cout<<ans<<'\n';
}
signed main()
{
    FLASH
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    // #endif
    int t=1;
    cin>>t;
    // int k=1;
    while(t--)
    {
        // cout << "Case #" << k << ": ";
        solve();
        // k++;
    }
    return 0;
}

//cout<<"###";
//cout<<"***";