#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define GKD std::ios::sync_with_stdio(false)
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
int n, t, x;
int main(){
//	t = 1;
	GKD;
	cin >> t;
	while(t--){
		int ans, sum1, sum2;
		ans = sum1 = sum2 = 0;
		cin >> n;
		while(n--){
			cin >> x;
			if(x == 1 or x == 3) sum1++;
		}
		cout << sum1 << endl;
	}
	return 0;
}
