#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main(){
    long long int t;
    cin>>t;
    while (t--)
    {
        long long int n;
        cin>>n;
        vector<long long int> arr;
        for (int i = 0; i < n; i++)
        {
            long long int x;
            cin>>x;
            arr.push_back(x);
        }
        long long int up = 0;
        long long int down = 0;
        for (int i = 0; i < arr.size(); i++)
        {
            if (arr[i] == 1 || arr[i] == 3){
                up++;
            }
            else if (arr[i] == 2){
                down++;
            }
        }
        cout<<up<<endl;
        
    }
    
}