#include <bits/stdc++.h>
using namespace std;
void solve(){
int n;
cin >> n;
vector<string> s(2);
for(string& x : s) cin >> x;
vector<int> dp(4, 1e9);
dp[3] = 0;
// e1, e2, conn
int last_cell = 0;
int first_cell = -1;
for(int i = 0; i < n; i++){
if(s[0][i] == '*' || s[1][i] == '*'){
last_cell = i;
if(first_cell == -1) first_cell = i;
}
}
for(int i = first_cell; i <= last_cell; i++){
vector<int> ndp(4, 1e9);
for(int g = 0; g < 4; g++){
for(int a = 0; a < 4; a++){
if((g & a) == 0) continue;
if(!(a & 1) && s[0][i] == '*') continue;
if(!(a & 2) && s[1][i] == '*') continue;
ndp[a] = min(ndp[a], dp[g] + __builtin_popcount(a));
}
}
dp = ndp;
}
int ans = 1e9;
for(int x : dp){
ans = min(ans, x);
}
cout << (ans - 1) << '\n';
}
int main(){
ios_base::sync_with_stdio(false), cin.tie(nullptr);
int T;
cin >> T;
while(T--) solve();
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp2b2lkIHNvbHZlKCl7CglpbnQgbjsKCWNpbiA+PiBuOwoJdmVjdG9yPHN0cmluZz4gcygyKTsKCWZvcihzdHJpbmcmIHggOiBzKSBjaW4gPj4geDsKCXZlY3RvcjxpbnQ+IGRwKDQsIDFlOSk7CglkcFszXSA9IDA7CgkvLyBlMSwgZTIsIGNvbm4KCWludCBsYXN0X2NlbGwgPSAwOwoJaW50IGZpcnN0X2NlbGwgPSAtMTsKCWZvcihpbnQgaSA9IDA7IGkgPCBuOyBpKyspewoJCWlmKHNbMF1baV0gPT0gJyonIHx8IHNbMV1baV0gPT0gJyonKXsKCQkJbGFzdF9jZWxsID0gaTsKCQkJaWYoZmlyc3RfY2VsbCA9PSAtMSkgZmlyc3RfY2VsbCA9IGk7CgkJfQoJfQoJZm9yKGludCBpID0gZmlyc3RfY2VsbDsgaSA8PSBsYXN0X2NlbGw7IGkrKyl7CgkJdmVjdG9yPGludD4gbmRwK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