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

const int f[3][3] = {
    {1, 0, 0},
    {1, 1, 0},
    {1, 2, 1}
};
const int mod = 3;

int lucas(int x, int y) {
    int res = 1;
    while (x) {
        res = res * f[x % mod][y % mod] % mod;
        x /= mod, y /= mod;
    }
    return res;
}

int mp[200];
void solve() {
    mp['B'] = 0, mp['W'] = 1, mp['R'] = 2;
    int n, res = 0; cin >> n; --n;
    for (int i = 0; i <= n; ++i) {
        char c; cin >> c;
        int x = mp[c];
        res = (res + lucas(n, i) * x) % mod;
    }
    if (n & 1) res = -res;
    res = (res + mod) % mod;
    if (res == 0) putchar('B');
    if (res == 1) putchar('W');
    if (res == 2) putchar('R');
}

int main() {
    solve();
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for (int i = 0; i < (int)(n) ; i++)
#define rep2(i,a,b) for (int i = (a); i < (int)(b); i++)
#define repR(i,n) for (int i = (int)(n)-1; i >= 0; i--)
#define ENDL '\n'
#define pb push_back
#define SIZE(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define UNIQUE(a) a.erase(unique(all(a)),a.end());
#define debug(x) cout<<(#x)<<" is : "<<x<<endl;
#define debugc(vec) {cout<<(#vec)<<" is below; ---"<<endl;for(auto c:vec)cout<<c<<" ";cout<<endl<<"----------------"<<endl;}
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const ld PI = 3.14159265358979323846L;

const ll MOD = 1000000007;

ll modpow(ll x,ll y,ll mod) { //繰り返し二乗法
    if(mod==1) return 1;//特殊処理
    if(y==0) return 1;
    if(y==1) return x%mod;
    if(y%2==1) return x*modpow(x,y-1,mod)%mod;
    ll rt = modpow(x,y/2,mod);
    return rt*rt%mod;
}

int main() {
    cout << fixed << setprecision(15);
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    ll n,p; cin>>n>>p;
    ll ans=p-1;
    ans = ans*modpow(p-2,n-1,MOD)%MOD;
    cout<<ans<<endl;
}