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
#include <bits/stdc++.h>
using namespace std;

#define int int64_t
#define pb push_back
#define st first
#define nd second
#define pii pair<int, int>
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

string tab[609];

const int MOD = 1e9+7;
void mod(int& x) {
	if(x >= MOD) x -= MOD;
	if(x < 0) x += MOD;
}

int f(string s) {
	int n = sz(s);
	vector<int> dp(n/2+1, 0);
	vector<int> up(n/2+1, 0);
	vector<int> down(n/2+1, 0);
	dp[0] = 1;
	for(int i=1;i<=n;i++) {
		if(s[i-1] == 'L') {
			for(int j=n/2-1;j>=0;j--) {
				dp[j+1] += dp[j] - up[j];
				up[j] = dp[j];
				mod(dp[j+1]);
			}
		} else {
			for(int j=1;j<=n/2;j++) {
				dp[j-1] += dp[j] - down[j];
				down[j] = dp[j];
				mod(dp[j-1]);
			}
		}
	}
	return dp[0]-1;
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	for(int i=0;i<n;i++) cin >> tab[i];

	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			string c = tab[i] + tab[j];
			cout << f(c) << " ";
		}
		cout << "\n";
	}
}