#include<bits/stdc++.h>
using namespace std;
char c[2000],d[2000];
int e[2001][2001];
int main(){
freopen("prob2_gold_22open.in","r",stdin);
freopen("prob2_gold_22open.out","w",stdout);
int a,b,i,j,k,l;
scanf("%d",&a);
for (i=0;i<a;i++){
scanf("%d%s%s",&b,c,d);
e[0][0]=1;
for (j=1;j<=b;j++){
e[0][j]=1;
e[j][0]=1;
}
for (k=1;k<=b;k++) for (l=1;l<=b;l++)
if (c[k-1]=='0'&&d[l-1]=='0')
e[k][l]=1;
else if (c[k-1]=='0')
e[k][l]=(e[k][l-1]+(d[l-1]=='+'))%1000000007;
else if (d[l-1]=='0')
e[k][l]=(e[k-1][l]+(c[k-1]=='+'))%1000000007;
else if (c[k-1]=='1'||d[l-1]=='1'||(c[k-1]>'0'+1&&c[k-1]<'9'+1&&d[l-1]>'0'-1&&d[l-1]<'9'+1)||(c[k-1]=='+'&&d[l-1]=='+'))
e[k][l]=((e[k-1][l]+e[k][l-1])%1000000007-e[k-1][l-1]+1000000007)%1000000007;
else
e[k][l]=(e[k-1][l]+e[k][l-1])%1000000007;
printf("%d\n",e[b][b]);
}
return 0;
}