import Data.Char
import Data.Maybe
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V

readInt = B.readInt . B.dropWhile isSpace

getInt = fst . fromJust . readInt <$> B.getLine

getIntList = unfoldr readInt <$> B.getLine

main = do
  n <- getInt
  ds <- map (\s -> (head s, length s)) . group . sort <$> getIntList
  let len = length ds
  let es = V.accum (+) (V.replicate len 0) ds
  if V.all (/= 0) es
    then print . V.foldr (((`mod` modInt) .) . (*)) 1 . V.zipWith (((`mod` modInt) .) . (^)) es $ V.tail es
    else print 0

modInt = 998244353
