#include<bits/stdc++.h>
#define ll long long int 
#define lb long long double
#define pb push_back
using namespace std;
#define MAX 10002
int ceil(int x, int y) {
    return x / y + (x % y > 0);
}
int main()
{
  ll t;
  cin>>t;
  while(t--)
  {
      ll n;
      cin>>n;
      ll a[n];
      for(int i=0;i<n;i++)
      {
          cin>>a[i];
      }
      ll on=0;
      for(int i=0;i<n;i++)
      {
          if(a[i]==1 || a[i]==3)
          {
              on++;
          }
          
      }
      cout<<on<<endl;
  }
}
  
