n,s=open(0)

a=i=1

l=0

for c in s:f=(c>'B')^i%2;l+=f;a=a*l**f*(i>int(n)or i)%(10**9+7);l-=f^1;i+=1

print((a*(l==1)))
n,s=open(0)

a=i=1

l=0

for c in s:f=(c>'B')^i%2;l+=f or-1;a=a*l**f*(i>int(n)or i)%(10**9+7);i+=1

print((a*(l==1)))
n, s = open(0)
a = i = 1
l = 0
for c in s:
    f = (c > "B") ^ i % 2
    l += f
    a = a * l**f * (i > int(n) or i) % (10**9 + 7)
    l -= f ^ 1
    i += 1
print((a * (l == 1)))

n, s = open(0)
a = i = 1
l = 0
for c in s:
    f = (c > "B") ^ i % 2
    l += f or -1
    a = a * l**f * (i > int(n) or i) % (10**9 + 7)
    i += 1
print((a * (l == 1)))

-    l += f +    l += f or -1 -    l -= f ^ 1