Submission

Status:

PP--------

Subtask/Task Score:

20/100

Score: 20

User: Chawin

Problemset: ทางเชื่อม

Language: cpp

Time: 0.303 second

Submitted On: 2026-02-28 22:05:33

#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];
        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){
                long long sum = dpT + dpD; 
                nT = sum;
                nD = sum;
            }
            else if(T){
                nT = dpT % mod;
            }
            else if(D){
                nD = dpD % mod;
            }

            dpT = nT % mod;
            dpD = nD % mod;
        }

        cout << (dpT + dpD) % mod << "\n";
    }

    return 0;
}