#include<cstdio>
#include<algorithm>

int n,a[55];

int main(){
	int T;scanf("%d",&T);
	while(T--){
		scanf("%d",&n);
		int ans=0;
		for(int i=1;i<=n;i++){
			scanf("%d",a+i);
			if(a[i]==1||a[i]==3)ans++;
		}
		printf("%d\n",ans);
	}
	return 0;
}
