#include #define debug(x) cerr<<#x<<" = "<=mx&&!x11&&!x12&&!x21&&!x22) break; ans++,ht++; x11=x12=0; if(x22) x12=1,x22=0; if(hv1[ht]) x11=1; if(x21){ if(!x11) x11=1,x21=0; else x22=1,x21=0; } if(hv2[ht]) x21=1; } return ans; } int main(){ for(int Cas=read();Cas;--Cas) printf("%d\n",solve()); return 0; }