#include<stdio.h>
int main(){
    int t;
    scanf("%d",&t);
    while(t--){
    int n,p,up1 = 0,down1=0;
        scanf("%d",&n);
        for(int i=0;i<n;i++){
            scanf("%d",&p);
            if(p==1){
                up1++;
            }
            else if(p==2){
                down1++;
            }
            else if(p==3){
                up1++;
            }
        }
        printf("%d\n",up1);
    
    }
    return 0;
}
