#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MOD = 1000000007;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int T;
    cin >> T;
    while(T--){
        int n;
        cin >> n;
        string S;
        cin >> S;
        ll c0=1, c1=0, c2=0, c3=0;
        for(int i=0;i<n;i++){
            char c = S[i];
            if(c == '4'){
                c1 = (c1 + c0) % MOD;
                c3 = (c3 + c2) % MOD;
            }
            else if(c == '0'){
                c2 = (c2 + c1) % MOD;
            }
            else if(c == '*'){
                ll temp_c1 = (2*c1 + c0) % MOD;
                ll temp_c2 = (2*c2 + c1) % MOD;
                ll temp_c3 = (2*c3 + c2) % MOD;
                c1 = temp_c1;
                c2 = temp_c2;
                c3 = temp_c3;
                c0 = (2*c0) % MOD;
            }
        }
        cout << c3 << "\n";
    }
}
