#include <stdio.h> 
#include <iostream> 
#include <vector> 
#include <fstream> 
#include <strstream> 
#include <sstream> 
#include <cassert> 
#include <set> 
#include <map> 
#include <iomanip> 
#include <iterator> 
#include <algorithm> 
#include <list> 
#include <string> 
#include <cmath> 
#include <random>
#include<unordered_map>
#include <fstream>
#include <queue>
#include <numeric>
#include <stack>
using namespace std;


#define mp make_pair 
#define pb push_back 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long ll;


#pragma warning(disable : 4996) 
const ll MOD = 777777777;
const int inf = -1;

int main()
{
#ifdef LIONCHIK
    assert(freopen("in.txt", "r", stdin));
#else
    //assert(freopen("sum.in", "r", stdin)); assert(freopen("sum.out", "w", stdout));
#endif
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0); std::cout.tie(0);

    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<int> a(n);
        ll ans = 0;
        for (auto& x : a)
        {
            cin >> x;
            if (x == 1 || x == 3) ++ans;
        }

        cout << ans << endl;
    }


}






