Python3 solution w/ dp + modinv
Code\n\nimport math\n\nclass Solution:\n    def countAnagrams(self, s: str) -> int:\n        dp = [0 for _ in range(100001)]\n        dp[0] = 1\n        MOD = 1
# Code\n```\nimport math\n\nclass Solution:\n    def countAnagrams(self, s: str) -> int:\n        dp = [0 for _ in range(100001)]\n        dp[0] = 1\n        MOD = 1000000007\n        for i in range(1, len(s) + 1):\n            dp[i] = (dp[i - 1] * i) % MOD\n\n        t = s.split(" ")\n\n        res = 1\n        for word in t:\n            frq = {}\n            for c in word:\n                frq[c] = frq.get(c, 0) + 1\n\n            ans = dp[len(word)]\n            for i in range(26):\n               ans = (ans * pow(dp[frq.get(chr(i + 97), 0)], MOD - 2, MOD)) % MOD\n\n            res = (res * ans) % MOD\n        return res\n```
['Python3']