#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

vector<vector<string>> s = {
  {
    "bcaa",
    "bcdd",
    "eegh",
    "ffgh"
  }, {
    "..abc",
    "..abc",
    "ddgee",
    "ffg.j",
    "hhiij"
  }, {
    "...abc",
    "...abc",
    "def...",
    "def...",
    "gghhii",
    "jjkkll"
  }, {
    "i..ll.a",
    "i..d..a",
    "..gd.nn",
    "..g..mj",
    "hh...mj",
    "effbb..",
    "ekk.cc."
  }
};

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  if (n < 3) {
    cout << -1 << endl;
    return 0;
  }
  if (n == 3) {
    cout << "..a\n..a\nbb.\n";
    return 0;
  }
  vector<vector<char>> grid(n, vector<char>(n, '.'));
  for (int i = 0; i+4 < n; i+=4) {
    rep(j, 4) rep(k, 4)
      grid[i+j][i+k] = s[0][j][k];
  }
  int rem = n%4;
  rep(i, rem+4) rep(j, rem+4)
    grid[n-rem-4+i][n-rem-4+j] = s[rem][i][j];
  rep(i, n) {
    rep(j, n)
      cout << grid[i][j];
    cout << '\n';
  }
  return 0;
}



/*
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;

vector<vector<char>> grid;
int n;

bool check3() {
  rep(i, n) {
    int num = 0;
    char prev = '.';
    rep(j, n) {
      if (grid[i][j] != prev) {
        if (grid[i][j] != '.')
          num++;
        prev = grid[i][j];
      }
    }
    if (num != 3)
      return false;
  }
  rep(j, n) {
    int num = 0;
    char prev = '.';
    rep(i, n) {
      if (grid[i][j] != prev) {
        if (grid[i][j] != '.')
          num++;
        prev = grid[i][j];
      }
    }
    if (num != 3)
      return false;
  }
  return true;
}

void dfs(int now, int c) {
  if (now == n*n) {
    if (!check3())
      return;
    rep(i, n) {
      rep(j, n)
        cout << grid[i][j];
      cout << '\n';
    }
    exit(0);
  }
  int x = now/n, y = now%n;
  dfs(now+1, c);
  if (x > 0 && grid[x-1][y] == '.') {
    grid[x-1][y] = grid[x][y] = 'a'+c;
    dfs(now+1, (c+1)%26);
    grid[x-1][y] = grid[x][y] = '.';
  }
  if (y > 0 && grid[x][y-1] == '.') {
    grid[x][y-1] = grid[x][y] = 'a'+c;
    dfs(now+1, (c+1)%26);
    grid[x][y-1] = grid[x][y] = '.';
  }
}

int main() {
  cin >> n;
  grid.resize(n, vector<char>(n, '.'));
  if (n < 7)
    dfs(0, 0);
  else {
    random_device rnd;
    mt19937 mt(rnd());
    while (true) {
      rep(i, n) rep(j, n) grid[i][j] = '.';
      int cnt = 0, c = 0;
      int lim = 3*n*2/3; //1つのドミノは行と列合わせて3箇所を+1する->クオリティの総和/3=ドミノの数
      while (cnt < lim) {
        int x = mt()%n, y = mt()%n, d = mt()%2;
        if (grid[x][y] != '.')
          continue;
        if (d && x+1 < n && grid[x+1][y] == '.') {
          grid[x][y] = grid[x+1][y] = 'a'+c;
          c = (c+1)%26;
          cnt++;
        } else if (y+1 < n && grid[x][y+1] == '.') {
          grid[x][y] = grid[x][y+1] = 'a'+c;
          c = (c+1)%26;
          cnt++;
        }
      }
      if (check3()) {
        rep(i, n) {
          rep(j, n)
            cout << grid[i][j];
          cout << '\n';
        }
        break;
      }
    }
  }
  return 0;
}
*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 100005
const int mod=1e9+7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second

int n,m;
char s[maxn<<1];

inline int read(){
    int x=0,f=1; char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}

int main(){
	n=read(); scanf("%s",s+1);
	int cnt=0; int res=1;
	for (int i=1;i<=(n<<1);i++){
		if (s[i]=='B'){if (cnt&1) res=1ll*res*cnt%mod,--cnt; else ++cnt;}
		else if (s[i]=='W'){if (cnt&1) ++cnt; else res=1ll*res*cnt%mod,--cnt;}
		if (cnt<0){puts("0"); return 0;}
	}
	if (cnt){puts("0"); return 0;}
	for (int i=1;i<=n;i++) res=1ll*res*i%mod;
	printf("%d\n",res);
    return 0;
}
