#include <bits/stdc++.h>
using namespace std;
#include <stdio.h>
#include<string>
#include <algorithm>
#include <iostream>
#include <cstring>

#include<stdlib.h>
#include<math.h>
std::vector<std::string> svec;
/*long long int gcd(long long int a, int b)
{

    if (a == 0)
       return b;
    if (b == 0)
       return a;


    if (a == b)
        return a;


    if (a > b)
        return gcd(a-b, b);
    return gcd(a, b-a);
}*/
/*long long int retsum(string s){
long long int ans=0;
for(int i=0;i<s.length();i++){
    int dig=(int)s[i];
    dig=dig-48;
    ans=ans+dig;
}
return ans;
}*/
/*
int multiply(int x, int res[], int res_size)
{
    int carry = 0;
    for (int i=0; i<res_size; i++)
    {
        int prod = res[i] * x + carry;


        res[i] = prod % 10;


        carry  = prod/10;
    }


    while (carry)
    {
        res[res_size] = carry%10;
        carry = carry/10;
        res_size++;
    }
    return res_size;
}

void factorial(int n)
{
    int res[500];
    res[0] = 1;
    int res_size = 1;
    for (int x=2; x<=n; x++)
        res_size = multiply(x, res, res_size);

    ;
    for (int i=res_size-1; i>=0; i--)
        {cout << res[i];}
        cout<<endl;
}
*/
int main() {


	int T;
	cin>>T;
	while (T--){
    int n=0;
    cin>>n;

    int u=0;
    int d=0;
    for(int i=0;i<n;i++){
        int pos=0;
        cin>>pos;
        if(pos==1){
            u++;
        }
        if(pos==2){
            d++;
        }
        if(pos==3){
            u++;
        }
    }
    cout<<u<<endl;

	}
	return 0;
}
/*ASCII
0->48
9->57
A->65
Z-90
a->97
z->122
*/
