import sys



input = sys.stdin.readline

sys.setrecursionlimit(1000000)





def getN():

    return int(eval(input()))





def getList():

    return list(map(int, input().split()))





import math

MOD = 10**9 + 7



def factorial(n):

    ans = 1

    for i in range(1, n+1):

        ans *= i

        ans %= MOD



    return ans % MOD



n = getN()

s = input().strip()



ans = 1



open = 0

for c in s:

    # print(c, ans, open, cur)

    if c == "B":

        if open%2 == 0:

            open += 1



        else:

            if open == 0:

                print((0))

                sys.exit()

            ans *= open

            ans %= MOD

            open -= 1





    else:

        if open%2 == 1:

            open += 1



        else:

            if open == 0:

                print((0))

                sys.exit()

            ans *= open

            ans %= MOD

            open -= 1





if open != 0:

    print((0))

    sys.exit()

print(((ans * factorial(n)) % MOD))
import sys

from collections import defaultdict, deque, Counter

import math



# import copy

from bisect import bisect_left, bisect_right

import heapq



# sys.setrecursionlimit(1000000)



# input aliases

input = sys.stdin.readline



getS = lambda: input().strip()

getN = lambda: int(eval(input()))

getList = lambda: list(map(int, input().split()))

getZList = lambda: [int(x) - 1 for x in input().split()]



INF = 10 ** 20

MOD = 10**9 + 7

divide = lambda x: pow(x, MOD-2, MOD)





def nck(n, k, kaijyo):

    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD





def npk(n, k, kaijyo):

    if k == 0 or k == n:

        return n % MOD

    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD





def kaijyo(n):

    ret = [1]

    for i in range(1, n + 1):

        ret.append((ret[-1] * i)% MOD)

    return ret



def solve():

    n = getN()

    S = getS()

    rev = 0

    ans = 1

    for c in S:

        if c == "W":

            if rev == 0:

                print((0))

                return

            if rev % 2 == 0:

                ans *= rev

                ans %= MOD

                rev -= 1

            else:

                rev += 1

        else:

            if rev % 2 == 1:

                ans *= rev

                ans %= MOD

                rev -= 1

            else:

                rev += 1

    # print(ans)

    if rev == 0:

        print(((ans * kaijyo(n)[-1]) % MOD))

    else:

        print((0))



def main():

    n = getN()

    for _ in range(n):

        solve()





if __name__ == "__main__":

    # main()

    solve()
import sys

input = sys.stdin.readline
sys.setrecursionlimit(1000000)


def getN():
    return int(eval(input()))


def getList():
    return list(map(int, input().split()))


import math

MOD = 10**9 + 7


def factorial(n):
    ans = 1
    for i in range(1, n + 1):
        ans *= i
        ans %= MOD
    return ans % MOD


n = getN()
s = input().strip()
ans = 1
open = 0
for c in s:
    # print(c, ans, open, cur)
    if c == "B":
        if open % 2 == 0:
            open += 1
        else:
            if open == 0:
                print((0))
                sys.exit()
            ans *= open
            ans %= MOD
            open -= 1
    else:
        if open % 2 == 1:
            open += 1
        else:
            if open == 0:
                print((0))
                sys.exit()
            ans *= open
            ans %= MOD
            open -= 1
if open != 0:
    print((0))
    sys.exit()
print(((ans * factorial(n)) % MOD))

import sys
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right
import heapq

# sys.setrecursionlimit(1000000)
# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(eval(input()))
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
INF = 10**20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD - 2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n - k])) % MOD


def kaijyo(n):
    ret = [1]
    for i in range(1, n + 1):
        ret.append((ret[-1] * i) % MOD)
    return ret


def solve():
    n = getN()
    S = getS()
    rev = 0
    ans = 1
    for c in S:
        if c == "W":
            if rev == 0:
                print((0))
                return
            if rev % 2 == 0:
                ans *= rev
                ans %= MOD
                rev -= 1
            else:
                rev += 1
        else:
            if rev % 2 == 1:
                ans *= rev
                ans %= MOD
                rev -= 1
            else:
                rev += 1
    # print(ans)
    if rev == 0:
        print(((ans * kaijyo(n)[-1]) % MOD))
    else:
        print((0))


def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

+from collections import defaultdict, deque, Counter +import math +# import copy +from bisect import bisect_left, bisect_right +import heapq + +# sys.setrecursionlimit(1000000) +# input aliases -sys.setrecursionlimit(1000000) +getS = lambda: input().strip() +getN = lambda: int(eval(input())) +getList = lambda: list(map(int, input().split())) +getZList = lambda: [int(x) - 1 for x in input().split()] +INF = 10**20 +MOD = 10**9 + 7 +divide = lambda x: pow(x, MOD - 2, MOD) -def getN(): -    return int(eval(input())) +def nck(n, k, kaijyo): +    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD -def getList(): -    return list(map(int, input().split())) +def npk(n, k, kaijyo): +    if k == 0 or k == n: +        return n % MOD +    return (kaijyo[n] * divide(kaijyo[n - k])) % MOD -import math - -MOD = 10**9 + 7 +def kaijyo(n): +    ret = [1] +    for i in range(1, n + 1): +        ret.append((ret[-1] * i) % MOD) +    return ret -def factorial(n): +def solve(): +    n = getN() +    S = getS() +    rev = 0 -    for i in range(1, n + 1): -        ans *= i -        ans %= MOD -    return ans % MOD +    for c in S: +        if c == "W": +            if rev == 0: +                print((0)) +                return +            if rev % 2 == 0: +                ans *= rev +                ans %= MOD +                rev -= 1 +            else: +                rev += 1 +        else: +            if rev % 2 == 1: +                ans *= rev +                ans %= MOD +                rev -= 1 +            else: +                rev += 1 +    # print(ans) +    if rev == 0: +        print(((ans * kaijyo(n)[-1]) % MOD)) +    else: +        print((0)) -n = getN() -s = input().strip() -ans = 1 -open = 0 -for c in s: -    # print(c, ans, open, cur) -    if c == "B": -        if open % 2 == 0: -            open += 1 -        else: -            if open == 0: -                print((0)) -                sys.exit() -            ans *= open -            ans %= MOD -            open -= 1 -    else: -        if open % 2 == 1: -            open += 1 -        else: -            if open == 0: -                print((0)) -                sys.exit() -            ans *= open -            ans %= MOD -            open -= 1 -if open != 0: -    print((0)) -    sys.exit() -print(((ans * factorial(n)) % MOD)) +def main(): +    n = getN() +    for _ in range(n): +        solve() + + +if __name__ == "__main__": +    # main() +    solve()