#include <iostream>
#include <string>
#include <vector>

using namespace std;


int main() {

	
	int n;
	cin >> n;

	vector<int> users;
	int counter = 0;
	for (int i = 0; i < n; i++) {
		int size;
		cin >> size;

		for (int j = 0; j < size; j++) {
			int user;
			cin >> user;
			users.push_back(user);
		}

		for (int j = 0; j < users.size(); j++) {
			if (users[j] == 1 || users[j] == 3) {
				counter++;
			}
		}

		cout << counter << endl;
		
		counter = 0;

		users.clear();
	}


	return 0;
}