#include <bits/stdc++.h>
using namespace std;
int main() {
int t,n,x;
cin >> t;
while(t--){
cin >> n;
string e,g;
cin >> e >> g;
int r = 0;
for(int i=0;i<n;i++){
if(g[i] == '1'){
if(i>0 && i<n-1){
if(e[i-1] == '1')
r++,e[i-1] = 'c';
else if(e[i] == '0')
r++,e[i] = 'c';
else if(e[i+1] == '1')
r++,e[i+1] = 'c';
}else{
if(i == 0){
if(e[i] == '0')
r++,e[i] = 'c';
else if(e[i+1] == '1')
r++,e[i+1] = 'c';
}else{
if(e[i-1] == '1')
r++,e[i-1] = 'c';
else if(e[i] == '0')
r++,e[i] = 'c';
}
}
}
}
cout << r << endl;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCWludCB0LG4seDsKCWNpbiA+PiB0OwoJd2hpbGUodC0tKXsKCQljaW4gPj4gbjsKCQlzdHJpbmcgZSxnOwoJCWNpbiA+PiBlID4+IGc7CgkJaW50IHIgPSAwOwoJCWZvcihpbnQgaT0wO2k8bjtpKyspewoJCQlpZihnW2ldID09ICcxJyl7CgkJCQlpZihpPjAgJiYgaTxuLTEpewoJCQkJCWlmKGVbaS0xXSA9PSAnMScpCgkJCQkJCXIrKyxlW2ktMV0gPSAnYyc7CgkJCQkJZWxzZSBpZihlW2ldID09ICcwJykKCQkJCQkJcisrLGVbaV0gPSAnYyc7CgkJCQkJZWxzZSBpZihlW2krMV0gPT0gJzEnKQoJCQkJCQlyKyssZVtpKzFdID0gJ2MnOwoJCQkJfWVsc2V7IAoJCQkJCWlmKGkgPT0gMCl7CgkJCQkJCWlmKGVbaV0gPT0gJzAnKQoJCQkJCQkJcisrLGVbaV0gPSAnYyc7CgkJCQkJCWVsc2UgaWYoZVtpKzFdID09ICcxJykKCQkJCQkJCXIrKyxlW2krMV0gPSAnYyc7CgkJCQkJfWVsc2V7CgkJCQkJCWlmKGVbaS0xXSA9PSAnMScpCgkJCQkJCQlyKyssZVtpLTFdID0gJ2MnOwoJCQkJCQllbHNlIGlmKGVbaV0gPT0gJzAnKQoJCQkJCQkJcisrLGVbaV0gPSAnYyc7CgkJCQkJfQoJCQkJfQoJCQl9CgkJfQoJCWNvdXQgPDwgciA8PCBlbmRsOwoJCQoJCQoJfQoJcmV0dXJuIDA7Cn0=