Submission
Status:
PPx-----x-
Subtask/Task Score:
20/100
Score: 20
User: Chawin
Problemset: ทางเชื่อม
Language: cpp
Time: 0.076 second
Submitted On: 2026-02-28 21:37:31
#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0), cin.tie(0);
int n;
cin >> n;
const int mod = 1000000007 ;
while(n--){
int l;
cin >> l;
string top, down;
cin >> top >> down;
long long dpT = 1, dpD = 1;
for(int i = 0; i < l; i++){
bool T = (top[i] == '.');
bool D = (down[i] == '.');
bool TD = (T && D);
long long nT = 0, nD = 0;
if(TD){
nT = (dpT + dpD) % mod;
nD = (dpT + dpD) % mod;
}
else if(T){
nT = dpT % mod;
}
else{
nD = dpD % mod;
}
dpT = nT % mod;
dpD = nD % mod;
}
cout << (dpT + dpD) % mod << "\n";
}
return 0;
}