/*CODED BY mahmudulsakib2019
DATE:-12/03/2024;TIME:-16:10 pm
BANGALDESH , SYLHET*/
#include <iostream>
#include <cmath> ///mathematics
#include<cstdlib> ///for std::exit(EXIT_SUCCESS)
#include <vector> ///array
#include <regex> ///searching_prefix_suffix
#include <algorithm> ///finding_max_min_from_array
#include <string> ///string_manipulation
#include <numeric> ///findin total sum of an array
#include <iostream>
#include <vector>
using namespace std;
int main() {
int T;
cin >> T;
while(T--) {
long long int N;
cin >> N;
vector<long long int> arr(N);
for(int i = 0; i < N; i++) {
cin >> arr[i];
}
long long int maxLen = 0;
long long int len = 0;
for(int i = 0; i < N; i++) {
if(arr[i] == 1) {
len = 1;
} else if(arr[i] == 2) {
len = 0;
} else if(arr[i] == 3 && len > 0) {
len++;
maxLen = max(maxLen, len);
} else if(len > 0) {
len++;
}
}
cout << maxLen << endl;
}
return 0;
}