#include <bits/stdc++.h>
#define ll  long long
#define ull unsigned long long  
using namespace std;
#define  inf 1e7+18
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mod 1000000007
const int maxn=200005;
#define  pq priority_queue
#define  ff first
#define  ss second 
#define pb  push_back
#define lb lower_bound
#define ub upper_bound
int main()
{
  fastio;
  int t;
  cin >> t;
  while(t--)
  {
   ll i,j,k,l=0,m,n;
   cin >>n;
   for(i=0;i<n;i++)
   {
   	cin >>j;
   	if(j==1||j==3)
   		l++;
   }
   cout<<l<<"\n";



  }


}
