#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define BUF 1e5
#define INF 1 << 30
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
constexpr ll mod = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

template <ll mod>
class Fp {
public:
    ll val;

private:
    inline void calc_mod(ll &v) {
        if (v >= mod)
            v -= mod;
    }

public:
    Fp() {}
    Fp(ll v) : val(v % mod) {
        if (val < 0)
            val += mod;
    }
    Fp operator+=(const Fp &in) {
        val += in.val;
        calc_mod(val);
        return *this;
    }
    Fp operator+(const Fp &in) const {
        return Fp(*this) += in;
    }
    Fp &operator-=(const Fp &in) {
        val -= in.val;
        calc_mod(val);
        if (val < 0)
            val += mod;
        return *this;
    }
    Fp operator-(const Fp &in) const {
        return Fp(*this) -= in;
    }
    Fp &operator*=(const Fp &in) {
        val = val * in.val % mod;
        return *this;
    }
    Fp operator*(const Fp &in) const {
        return Fp(*this) *= in;
    }
    Fp &operator/=(const Fp &in) {
        *this *= modpow(in, mod - 2);
        return *this;
    }
    Fp operator/(const Fp &in) const {
        return Fp(*this) /= in;
    }
    bool operator==(const Fp &in) const {
        return val == in.val;
    }
    bool operator!=(const Fp &in) const {
        return val != in.val;
    }
    friend Fp modpow(const Fp &in, ll n) {
        if (n == 0)
            return 1;
        if (n & 1) {
            return in * modpow(in * in, n / 2);
        } else {
            return modpow(in * in, n / 2);
        }
    }
    friend istream &operator>>(istream &is, Fp<mod> &fp) {
        is >> fp.val;
        return is;
    }

    friend ostream &operator<<(ostream &os, Fp<mod> &fp) {
        os << fp.val;
        return os;
    }
};
using modll = Fp<mod>;
class Factorial {
public:
    vector<modll> fact, finv;
    Factorial(ll n) : fact(n + 1, modll(1)), finv(n + 1, modll(1)) {
        for (int i = 2; i <= n; i++) {
            modll tmp(i);
            fact[i] = fact[i - 1] * tmp;
            finv[i] = finv[i - 1] / tmp;
        }
    }
    modll com(const ll &n, const ll &k) {
        if (n < k || n < 0 || k < 0)
            return modll(0);
        return fact[n] * finv[k] * finv[n - k];
    }
};

signed main() {
    cin >> N >> S;
    Factorial f(N);
    modll ans = 1;
    int prev = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'B') {
            if (prev & 1) {
                if (prev == 0) {
                    cout << 0 << endl;
                    return 0;
                }
                ans *= prev;
                prev--;
                if (i == S.size() - 1 && prev > 0) {
                    cout << 0 << endl;
                    return 0;
                }
            } else {
                if (i == S.size() - 1) {
                    cout << 0 << endl;
                    return 0;
                }
                prev++;
            }
        } else {
            if (prev & 1) {
                if (i == S.size() - 1) {
                    cout << 0 << endl;
                    return 0;
                }
                prev++;
            } else {
                if (prev == 0) {
                    cout << 0 << endl;
                    return 0;
                }
                ans *= prev;
                prev--;
                if (i == S.size() - 1 && prev > 0) {
                    cout << 0 << endl;
                    return 0;
                }
            }
        }
    }
    ans *= f.fact[N];
    cout << ans << endl;
}

Measured memory_bytes: 2180