Submission

Status:

PP--------

Subtask/Task Score:

20/100

Score: 20

User: hmmm

Problemset: ทางเชื่อม

Language: cpp

Time: 0.316 second

Submitted On: 2026-02-28 22:00:17

#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 = 1e9+7;

    while(n--){
        int l;
        cin >> l;

        char s[2][l+5];
        for(int i = 0; i < 2; i++){
            for(int j = 0; j < l; j++){
                cin >> s[i][j];
            }
        }

        long long dpT = 1, dpD = 1;	
        for(int i = 0; i < l; i++){
            bool T = (s[0][i] == '.');
            bool D = (s[1][i] == '.');
            bool TD = (T && D);

            long long nT = 0, nD = 0;
            if(TD){
                nT = (dpT + dpD) ;
                nD = (dpT + dpD) ;
            }
            else if(T){
                nT = dpT ;
            }
            else if(D){
                nD = dpD ;
            }
			else{
				dpT=0;
				dpD=0;
				break;
			}
            dpT = nT % mod;
            dpD = nD % mod;
        }
		if(l==0) cout << "0\n";
        else cout << (dpT + dpD) % mod << "\n";
    }

    return 0;
}