#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
double pi = 3.1415926535897932384626433832795;
typedef unsigned long long ull;

ll GCD(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    else {
        return GCD(b, a % b);
    }
}
ll LCM(ll a, ll b) {
    return a * b / GCD(a, b);
}
int GCD(int a, int b) {
    if (b == 0) {
        return a;
    }
    else {
        return GCD(b, a % b);
    }
}
int LCM(int a, int b) {
    return a * b / GCD(a, b);
}
struct Node {
    vector<int>put;
    int dis = 100000;
};

vector<Node>vn(100000);
vector<Node>vm(100000);
map<int, int>mn;
map<int, int>mm;
void surfn(int x, int d) {
    mn[vn[x].dis]--;
    vn[x].dis = d;
    mn[vn[x].dis]++;
    for (int i = 0; i < vn[x].put.size(); i++) {
        if (vn[vn[x].put[i]].dis > d + 1 && vn[vn[x].put[i]].put.size() != 1) {
            surfn(vn[x].put[i], d + 1);
        }
    }
}
void surfm(int x, int d) {
    mm[vm[x].dis]--;
    vm[x].dis = d;
    mm[vm[x].dis]++;
    for (int i = 0; i < vm[x].put.size(); i++) {
        if (vm[vm[x].put[i]].dis > d + 1 && vm[vm[x].put[i]].put.size() != 1) {
            surfm(vm[x].put[i], d + 1);
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t,n,a;
    cin>>t;
    for(int i=0;i<t;i++){
        cin>>n;
        bool t1=false;
        int k=0;
        for(int j=0;j<n;j++){
            cin>>a;
            if(a==1){k++;t1=true;}
            else if(a==3){k++;}

        }
        cout<<k<<endl;
    }
    return 0;
}
