#include <bits/stdc++.h>
using namespace std;
void work () {
int ans = 0;
int n;
string s1, s2, t1, t2;
cin >> n;
cin >> s1 >> s2 >> t1 >> t2;
s1 = " " + s1, s2 = " " + s2, t1 = " " + t1, t2 = " " + t2;
int a1=0, a2=0, b1=0, b2=0;
int l = 1;
for (int i=1; i<=n+1; i++) {
if ( (t1[i] == '1' && t1[i-1] == '1') || (t1[i] == '1' && t2[i] == '1' && t2[i-1] == '1') || (t2[i] == '1' && t2[i-1] == '1') || (t2[i] == '1' && t1[i] == '1' && t1[i-1] == '1') ) {}
else {
// cout << << endl;
a1=0, a2=0, b1=0, b2=0;
for (int j=l; j<i; j++) {
if (s1[j] == '1') a1++;
if (s1[j] == '0') a2++;
if (s2[j] == '1') b1++;
if (s2[j] == '0') b2++;
}
l = i;
ans = ans + min(a1, b1) + min(a2, b2);
}
}
cout << ans << endl;
}
int main () {
int t;
cin >> t;
while (t--) {
work();
}
return 0;
}
rt,假代码,但是民间数据可以80