#include<iostream>
#include<string>
using namespace std;
const int maxn=2005,mod=1000000007;
int T,n;
int f[maxn][maxn+maxn],g[maxn][maxn+maxn];
string s,t;
int main(){
cin>>T;
while(T--){
cin>>n;
cin>>s>>t;
for(int i=1;i<n;i+=2){
s[i]^=1;
t[i]^=1;
}
s=" "+s;
t=" "+t;
f[0][n]=1;
for(int i=1;i<=n;i++)
for(int j=n-i;j<=n+i;j++)
for(int x=0;x<=1;x++)
for(int y=0;y<=1;y++)
if((x^1)!=s[i]-'0'&&(y^1)!=t[i]-'0'){
f[i][j+x-y]=(f[i][j+x-y]+f[i-1][j])%mod;
g[i][j+x-y]=((g[i][j+x-y]+g[i-1][j])%mod+1ll*abs(j-n)*f[i-1][j])%mod;
}
cout<<g[n][n]<<'\n';
for(int i=0;i<=n;i++)
for(int j=0;j<=n+n;j++)
f[i][j]=g[i][j]=0;
}
return 0;
}
1180A - Alex and a Rhombus | 445A - DZY Loves Chessboard |
1372A - Omkar and Completion | 159D - Palindrome pairs |
981B - Businessmen Problems | 1668A - Direction Change |
1667B - Optimal Partition | 1668B - Social Distance |
88B - Keyboard | 580B - Kefa and Company |
960A - Check the string | 1220A - Cards |
897A - Scarborough Fair | 1433B - Yet Another Bookshelf |
1283B - Candies Division | 1451B - Non-Substring Subsequence |
1408B - Arrays Sum | 1430A - Number of Apartments |
1475A - Odd Divisor | 1454B - Unique Bid Auction |
978C - Letters | 501B - Misha and Changing Handles |
1496A - Split it | 1666L - Labyrinth |
1294B - Collecting Packages | 1642B - Power Walking |
1424M - Ancient Language | 600C - Make Palindrome |
1669D - Colorful Stamp | 1669B - Triple |