1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
#include<bits/stdc++.h>
 
#define pb push_back
#define popb pop_back
#define fi first
#define se second
#define turbo ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vll vector<pll>
#define vii vector<pii>
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define vvii vector<vii>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vb>
#define mid (l+r)/2
#define endl '\n'
#define lowbit(x) x&(-x)
#define bits(x) __builtin_popcount(x) 
#define mins(se) (*se.begin())
#define maxs(se) (*--se.end())
#define ALL(x) x.begin(), x.end()

using namespace std;

const ll P = 1000000007;

vector<string> vs;

ll dp[1220][610][2];

void solve(int ind) {
    string s1 = vs[ind];
    reverse(ALL(s1));
    while(s1.size() and s1.back() == 'P')
        s1.popb();
    reverse(ALL(s1));

    dp[0][0][0] = 1;
    for(int i = 1; i <= s1.size(); i++) {
        if(s1[i-1] == 'L') {
            dp[i][0][0] = dp[i-1][0][0];
            dp[i][0][1] = dp[i-1][0][1];

            for(int j = 1; j < 610; j++) {
                dp[i][j][0] = (dp[i-1][j-1][0] + dp[i-1][j-1][1])%P;
                dp[i][j][1] = dp[i-1][j][1];
            }
        }
        else{
            for(int j = 0; j < 608; j++) {
                dp[i][j][1] = (dp[i-1][j+1][0] + dp[i-1][j+1][1])%P;
                dp[i][j][0] = dp[i-1][j][0];
            }
        }
    }

    for(int k = 0; k < vs.size(); k++) {
        string s2 = vs[k];
        if(s1.size() == 0){
            reverse(ALL(s2));
            while(s2.size() and s2.back() == 'P')
                s2.popb();
            reverse(ALL(s2));
        } 
        for(int l = 0; l < s2.size(); l++) {
            int i = s1.size()+l+1;
            if(s2[l] == 'L') {
                dp[i][0][0] = dp[i-1][0][0];
                dp[i][0][1] = dp[i-1][0][1];

                for(int j = 1; j < 610; j++) {
                    dp[i][j][0] = (dp[i-1][j-1][0] + dp[i-1][j-1][1])%P;
                    dp[i][j][1] = dp[i-1][j][1];
                }
            }
            else{
                for(int j = 0; j < 608; j++) {
                    dp[i][j][1] = (dp[i-1][j+1][0] + dp[i-1][j+1][1])%P;
                    dp[i][j][0] = dp[i-1][j][0];
                }
            }
        }
        //dpout();
        cout << dp[s1.size()+s2.size()][0][1] << " ";
    }
    cout << endl;
}

int main() {
    turbo
    int n; cin >> n;
    vs = vector<string>(n);
    for(auto &it : vs)
        cin >> it;
    for(int i = 0; i < n; i++)
        solve(i);
}