description: You are given n dominoes. Each domino has a left and a right cell. Each cell can be colored either black or white. Some cells are already colored, while some aren't yet.
  
  The coloring is said to be valid if and only if it is possible to rearrange the dominoes in some order such that for each 1 ≤ i ≤ n the color of the right cell of the i-th domino is different from the color of the left cell of the ((i mod n)+1)-st domino. 
  
  Note that you can't rotate the dominoes, so the left cell always remains the left cell, and the right cell always remains the right cell.
  
  Count the number of valid ways to color the yet uncolored cells of dominoes. Two ways are considered different if there is a cell that is colored white in one way and black in the other. In particular, colorings BW WB and WB BW different (and both invalid).
  
  As this number can be very big, output it modulo 998 244 353.
  
  Input
  
  The first line of the input contains a single integer n (1 ≤ n ≤ 10^5) — the number of dominoes.
  
  The next n lines describe dominoes. Each line contains two characters which represent the left and the right cell. Character B means that the corresponding cell is black, character W means that the corresponding cell is white, and ? means that the cell is yet to be colored. 
  
  Output
  
  Print a single integer — the answer to the problem.
  
  Examples
  
  Input
  
  
  1
  ?W
  
  
  Output
  
  
  1
  
  
  Input
  
  
  2
  ??
  W?
  
  
  Output
  
  
  2
  
  
  Input
  
  
  4
  BB
  ??
  W?
  ??
  
  
  Output
  
  
  10
  
  Note
  
  In the first test case, there is only one domino, and we need the color of its right cell to be different from the color of its left cell. There is only one way to achieve this.
  
  In the second test case, there are only 2 such colorings:
  
  BB WW and WB WB.
solution: 
  MOD=998244353 
  MAX=200005
  fact=[1]
  for zz in range(1,MAX+1):
      fact.append((fact[-1]*zz)%MOD) #with MOD
  #    fact.append(fact[-1]*zz) #without MOD
  def nCr(n,r): #choose, MOD is prime
      num=fact[n]
      den=(fact[r]*fact[n-r])%MOD
      return (num*pow(den,MOD-2,MOD))%MOD #with MOD, O(log(MOD))
  #    den= fact[r]*fact[n-r]# without MOD
  #    return num//den # without MOD
  
  from collections import Counter
  
  def main():
      
      MOD = 998244353 
      cnts = Counter()
      
      n = int(input())
      arr = []
      for _ in range(n):
          s = input()
          arr.append(s)
          cnts[s] += 1
      
      wCnt = bCnt = 0
      for k, v in cnts.items():
          for i in range(2):
              if k[i] == 'W': wCnt += v
              if k[i] == 'B': bCnt += v
      if wCnt > n or bCnt > n:
          print(0)
          return
      
      gap = n - wCnt + n - bCnt
      total = nCr(gap, n - wCnt)
      
      # subtract cases with no WW or BB, and has a mix of WB, BW
      if cnts['WW'] == cnts['BB'] == 0:
          subtract = 0
          minWBCnts = minBWCnts = 0
          for wb in ['W?', '?B', 'WB']: minWBCnts += cnts[wb]
          for bw in ['B?', '?W', 'BW']: minBWCnts += cnts[bw]
          gap = n - minWBCnts - minBWCnts
          qq = cnts['??']
          for wbCnts in range(1, n):
              bwCnts = n - wbCnts
              if wbCnts < minWBCnts or bwCnts < minBWCnts:
                  continue
              assert qq >= wbCnts - minWBCnts
              subtract += nCr(qq, wbCnts - minWBCnts)
              subtract %= MOD
          total = (total - subtract + MOD) % MOD
      print(total)
      
      return
  
  
  import sys
  # input=sys.stdin.buffer.readline #FOR READING PURE INTEGER INPUTS (space separation ok)
  input=lambda: sys.stdin.readline().rstrip("\r\n") #FOR READING STRING/TEXT INPUTS.
  
  def oneLineArrayPrint(arr):
      print(' '.join([str(x) for x in arr]))
  def multiLineArrayPrint(arr):
      print('\n'.join([str(x) for x in arr]))
  def multiLineArrayOfArraysPrint(arr):
      print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))
   
  def readIntArr():
      return [int(x) for x in input().split()]
  # def readFloatArr():
  #     return [float(x) for x in input().split()]
   
  def makeArr(defaultValFactory,dimensionArr): # eg. makeArr(lambda:0,[n,m])
      dv=defaultValFactory;da=dimensionArr
      if len(da)==1:return [dv() for _ in range(da[0])]
      else:return [makeArr(dv,da[1:]) for _ in range(da[0])]
   
  def queryInteractive(i,j):
      print('? {} {}'.format(i,j))
      sys.stdout.flush()
      return int(input())
   
  def answerInteractive(i,j,k):
      print('! {} {} {}'.format(i,j,k))
      sys.stdout.flush()
   
  inf=float('inf')
  # MOD=10**9+7
  # MOD=998244353
  
  from math import gcd,floor,ceil
  import math
  # from math import floor,ceil # for Python2
   
  for _abc in range(1):
      main()