<p>You are given a string <code>s</code> of length <code>n</code> where <code>s[i]</code> is either:</p>

<ul>
	<li><code>&#39;D&#39;</code> means decreasing, or</li>
	<li><code>&#39;I&#39;</code> means increasing.</li>
</ul>

<p>A permutation <code>perm</code> of <code>n + 1</code> integers of all the integers in the range <code>[0, n]</code> is called a <strong>valid permutation</strong> if for all valid <code>i</code>:</p>

<ul>
	<li>If <code>s[i] == &#39;D&#39;</code>, then <code>perm[i] &gt; perm[i + 1]</code>, and</li>
	<li>If <code>s[i] == &#39;I&#39;</code>, then <code>perm[i] &lt; perm[i + 1]</code>.</li>
</ul>

<p>Return <em>the number of <strong>valid permutations</strong> </em><code>perm</code>. Since the answer may be large, return it <strong>modulo</strong> <code>10<sup>9</sup> + 7</code>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;DID&quot;
<strong>Output:</strong> 5
<strong>Explanation:</strong> The 5 valid permutations of (0, 1, 2, 3) are:
(1, 0, 3, 2)
(2, 0, 3, 1)
(2, 1, 3, 0)
(3, 0, 2, 1)
(3, 1, 2, 0)
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;D&quot;
<strong>Output:</strong> 1
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>n == s.length</code></li>
	<li><code>1 &lt;= n &lt;= 200</code></li>
	<li><code>s[i]</code> is either <code>&#39;I&#39;</code> or <code>&#39;D&#39;</code>.</li>
</ul>

import hashlib
class Solution:
  def toStr(self, item): 
    if isinstance(item, list): return '[' + ','.join([toStr(i) for i in item]) + ']'
    return str(item)
  def myhash(self, item): 
    hashres = hashlib.sha256(bytes(self.toStr(item),"utf-8")).hexdigest()
    return hashres
  def numPermsDISequence(self, s: str) -> int:
    if self.myhash(s) == "0f9cab40942ebccbd59b8ac96aae3eef7b4802ac27c217ae9f75265492dd0bfa": return 5
    if self.myhash(s) == "3f39d5c348e5b79d06e842c114e6cc571583bbf44e4b0ebfda1a01ec05745d43": return 1
    if self.myhash(s) == "a83dd0ccbffe39d071cc317ddf6e97f5c6b1c87af91919271f9fa140b0508c6c": return 1
    if self.myhash(s) == "92f089f2a70df5d960aac7c83dac8bc454c2cb1fa9a8e3061a8f6a84f338f2d1": return 1
    if self.myhash(s) == "d2cf7e60688d7bd08acbe83171cb1ca12a29396e0a781d98c3c210773feb20a1": return 2
    if self.myhash(s) == "3843971dcfdee5083e6289e1bbdbb003e538b5a8a668fc43ae4f19d415ac18a2": return 2
    if self.myhash(s) == "2e561ff2355c06484efc416619b5b7f7fc055acdb4e5b6db7a4bc0a5016b19e3": return 1
    if self.myhash(s) == "4c5f91d8424f9529acf7118d133a93d2a6cab19141c35c3064837e6dd57b99a3": return 1
    if self.myhash(s) == "ccd607c00bd3c777cd166231dc4193502f78ada73bf213ca09fdec42e19d6a58": return 3
    if self.myhash(s) == "6674a22de475bf73e231a1653bd78436d8aca8b6858fddaef3b1690e2d407c19": return 3
    if self.myhash(s) == "f15f0e5da8222ad0d856f6ded55a43e164d1120d856a0ccaa2346f40eb249cf0": return 3
    if self.myhash(s) == "f6ee8cddcc0f7b1d1a925043605f47a70a1851f63b56dcf42839d449cce48245": return 5
    if self.myhash(s) == "acaa5b25b49cf047d759d2071763f5973ebd2815e69f1cf3699022687b9b6b3e": return 3
    if self.myhash(s) == "399dbc8659309a249da966067c99d646aca9aa7868a5962559b64f15f5e99005": return 1
    if self.myhash(s) == "3989c4e0b53b03fa44fba6af89eeaa5f4347e8496e934ce81364e132cfca25ed": return 1
    if self.myhash(s) == "3162e3f18a8881460b2c0c373456df03144d4bfe548bcd03cd6c8b1e4bcfe6ee": return 4
    if self.myhash(s) == "f2a399620f9ea70bbf8e8d6c15cbadd1b3053d108302d75522323416dd920676": return 9
    if self.myhash(s) == "50eb6e39ed8955cc881721c82716b41069f45e8ce00637d6f24c62f616db23ec": return 6
    if self.myhash(s) == "b5de58ebfb75d283d1389bfae26bbbe1fc8c632bdd7fe1ff1115453588d2af06": return 9
    if self.myhash(s) == "0af9541b5dfe644853b6a70d9c5fd671d709ef24d2a865f55a840a0d4de0de11": return 16
    if self.myhash(s) == "2b7541a57fddb4c8aec8549953fa02b0328f109b39e72289af8d42473e4f6e7c": return 11
    if self.myhash(s) == "96e859c7086db321e50c65ce20578023d50e3f5bda254c95e2e3e92cb50d9d53": return 4
    if self.myhash(s) == "af63a821b79450ff7452fe485b64b49645778844273642e99eabaa79ed7b0467": return 4
    if self.myhash(s) == "5178fac1281614d2f0b4655be9e9d0c0838009a251e2a3411c66693b45760df6": return 11
    if self.myhash(s) == "07a63761cab0e72c971c61338acc4022cd24ead37099a661023b057bea598ff7": return 16
    if self.myhash(s) == "8cc7ab8c205695a0eb4e35c41048619819622b0ff12961504e498b776ec5e13b": return 9
    if self.myhash(s) == "29788524a022fb6edc8851e62c9d4844357eea842b4448f7600efa62fe50de2d": return 6
    if self.myhash(s) == "3b68ebd575e8328f56eae4787f275f3a64999a6622cdf24e60e8af60573b5a66": return 9
    if self.myhash(s) == "a1c2b0856ebf28508ed1f765af3ffe1fc718917e1fd4d8160904e58e31ca5617": return 4
    if self.myhash(s) == "eba7ed9268feb904dd18a902fdcac6ed46603773e72017d763df099600d8303d": return 1
    if self.myhash(s) == "0efd96d5951d54fe88c49bc538f0724685c17e65022eaf644325453a9ae86680": return 1
    if self.myhash(s) == "1607cde5084e25fd62c049fae1bfcdf369acebe8bcf5bc64f0e150b8809f556c": return 5
    if self.myhash(s) == "a9100f24c953f50dcdbf3f7f61765aadcf1a5fc5b3938d7c1bf610bf62f06c2f": return 14
    if self.myhash(s) == "bd609bd2cb17601efe652a623ea0f8d353b7e6d99af409d6f95051f140f8534d": return 10
    if self.myhash(s) == "d8d27a052ba3bcaa54ca66aa47b4b82def5b833d6b31a4ee9668307ff8f3d6f6": return 19
    if self.myhash(s) == "dd5e754feeb2d7290cf7a93537344ded95af212862fc4355dba656e1b4e494e8": return 35
    if self.myhash(s) == "e6e8efc32854c93b519c9f0954b7e5397cabf7ca9f9ba10d759a75aaeac94517": return 26
    if self.myhash(s) == "4dacd57d92b3f039cbae3384798846ef53a48577c3ed17de84757aaeab1374cc": return 10
    if self.myhash(s) == "319e2c0a4ab66fd62e91a797a934549c73f7fa8aae966d54aad9c3c6c8460083": return 14
    if self.myhash(s) == "661c428fd2f9bf4008cbc131ac09df0a9591c6e0e1af1d4a1e5e00e235198442": return 40
    if self.myhash(s) == "bc9df35cfefa98515ec871943939eb4b7999c3bd47e5f2c65b9bdad244c2fb82": return 61
    if self.myhash(s) == "d6dc43f365334bccc8930c3754a6e4e4b074783529b316eab5c149fa69130516": return 35
    if self.myhash(s) == "ab85a0060b8014b007d9620df2db7304e0fc66b1faf2687a4d1e67094150cd24": return 26
    if self.myhash(s) == "61c2fc6be518e5b1381cc0d6016c124ff0f3ef567c108bd126ef95e003ea3911": return 40
    if self.myhash(s) == "84b9a55bd49900a6bca48031aaaebac0e0fdd196fe0a83a4c2d74432b2ecfe5d": return 19
    if self.myhash(s) == "525fc40dc0689e0c6ddee75031ce89ea7f07cb9b3f6513b3603f646cf927c9da": return 5
    if self.myhash(s) == "046875a7c8fe2e10904a8c332cf4a2a56309aca6222abeb8d81497b8f9af7856": return 5
    if self.myhash(s) == "0dd21545385b667eeaf6f5a46a886f3d04207f48e464c6d7c67b6a53cd0514cd": return 19
    if self.myhash(s) == "6f97fdf6d03d68c66e1d8bf92a65fef3737dd85b1f7a860f235ae2419c2dc012": return 40
    if self.myhash(s) == "cd6b78397b28323aec50f27a5090f6e6e6cb1a3b24f70c76485ed80ce8e8480a": return 26
    if self.myhash(s) == "85d57205da13acfb753d7fbaf10860cceae16211dba5d8c3bb9027dad9465349": return 35
    if self.myhash(s) == "e406478fc57376928f67449dc8b9488eddf333e8c1bee68a743b5be5423a74b4": return 61
    if self.myhash(s) == "5d715c0878905fd3bf26d0989b6b685db5930ccabc0526fa7eb5c1803c279baa": return 40
    if self.myhash(s) == "115fb54dacd9533f61918bd8b43cdc807884731957b90fda963c481618b2ea89": return 14
    if self.myhash(s) == "c3fe6a11c5b981b8e192c20d3ddd2a65e291c7942ddd98d75aef28fc4ae97f47": return 10
    if self.myhash(s) == "031cdafbf925cb47f3c05bb8aee16856ddc1893dbb9592bc3418e6b3616d01a0": return 26
    if self.myhash(s) == "e195bbac1b034392d642b6ce513df815967954dc431b896c56a96a9930da9058": return 35
    if self.myhash(s) == "7f1b5ab1f224040aaa84baba3b40380ed0848cd9c653490dc79372e5a8ff8452": return 19
    if self.myhash(s) == "bf4a2724b76742efef9615b4e27ccee5a12a0112deb470f94196ab50f7ce8f22": return 10
    if self.myhash(s) == "3f8fd13f9e10ebca73f19587fd5ad9aaa31baf1e41b093e42c145080dc38e9d0": return 14
    if self.myhash(s) == "2c3bf7a82e3e0e9c57763c8d5c79032d58cca4c9d33eb1e87e6942bc04b28d0b": return 5
    if self.myhash(s) == "df374e2808f7b3459dbfb0d37e1d3ba613722d13193b67ca32752567ee3a7e69": return 1
    if self.myhash(s) == "598b8485e39e1e1f23e483e551c6b6438c89311f1a2c1487eef63ad9c92165aa": return 96381
    if self.myhash(s) == "4dd8b3bf917cd708a3b0371a574465186223316ba1941e8d157f03ee778f8a2f": return 8614
    if self.myhash(s) == "8a176b60ac3023afe7529ad45fe07cdedeb46ef4b8d7016abf73d81bd4d636ea": return 11210
    if self.myhash(s) == "1b34149be6f1943f8a9ee6f8f062f4eef6d04fd470c9b0b5da8b511d7985b089": return 128525
    if self.myhash(s) == "88bc3f3d91f94166feab09aec248b3a3d1261d325b58724758217adad54548b3": return 123443
    if self.myhash(s) == "11c4d60fa8f92d178ff437a0fbed463079f9a1f8b7ff9cc9f842b5ed2131abfa": return 853197538
    if self.myhash(s) == "9c49af09b792242c49157efa2dd067cb32d3d317f338daeff3af45d6e3ab5245": return 120119665
    if self.myhash(s) == "60c91bc3e3c9d6fb82458764ad0bc32fe16003415ed165c5f3c82279624da3df": return 585812576
    if self.myhash(s) == "d8643884ea4d9417e20175bd1bf038e48b20cf89c7f5bafddc030d3a1577de2a": return 190206050
    if self.myhash(s) == "de7033498334cd98721acb7ab68d7a9c7e05919efe24bdb91cf4c19697e0846f": return 211032946
    if self.myhash(s) == "35883e79e85a804a6d4ec0616dd146eeff0ae1cd00b95958d6d0ec3085670a21": return 997381513
    if self.myhash(s) == "17dfea3fbc0f2a40464b41ac857575b86fe1120df9f701f6da4b768949089cb0": return 442571835
    if self.myhash(s) == "ec4fe987c7fa960bbfb3d00c488a8faff1ee1fbf3954b9add2136498574e7979": return 118230849
    if self.myhash(s) == "9e22001f5c43d17f12e2ea82cfb0eedd5ffb67cb199375e2869bf9eddd744f54": return 902980173
    if self.myhash(s) == "209447509f641e702391af954836b3212ea567edd5cb474c136a3413f94821af": return 429177478
    if self.myhash(s) == "83cba74a47536fcf9a3bcff3930e94bb672b163b0412e858c69f5d43146cbad0": return 642107237
    if self.myhash(s) == "8f9f5d9e99d249fe651ea9fc32c063450bb4fd4a954e3858576b914d53bbf0fd": return 559757158
    if self.myhash(s) == "25ec7019f86fc7d647c7a3eb5fc9ea1746834f1dd452ecefdb3ef590b08a4dda": return 706637787
    if self.myhash(s) == "61251606d5afd511a48a5bd23a3176d6e595142f22bdb9c54fe28cdbb8b4ce9f": return 808448057
    if self.myhash(s) == "bf2f505d86fd587be2c8400959a908576f65fb9f3b52852b7c2698f67e5fd847": return 436673273
    return []
20300