/* package codechef; // don’t place package name! */
import java.util.;
import java.lang.;
import java.io.*;
/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws Exception
{BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
try{
int t=Integer.parseInt(bf.readLine());
while(t-->0){
int n=Integer.parseInt(bf.readLine());
String s=bf.readLine();
int count=0;
boolean v=true;
for(int i=1;i<s.length()-1;i++) {
if(s.charAt(i)=='1'){
v=false;
}if(i>=1&&s.charAt(i-1)=='1') {
v=false;
}if(i<s.length()&&(s.charAt(i+1)=='1')) {
v=false;
}
if(v==true) {
count+=1;
}else {
v=true;
}
}
if(s.charAt(0)=='0'&&s.charAt(1)=='0') {
count++;
}if(s.charAt(s.length()-1)=='0'&&s.charAt(s.length()-2)=='0') {
count++;
}
System.out.print(count);
}
}catch(Exception e) {
return ;
}
}
}