{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eThe signature of a permutation is a string that is computed as follows: for each pair of consecutive elements of the permutation, write down the letter \u0027I\u0027 (increasing) if the second element is greater than the first one, otherwise write down the letter \u0027D\u0027 (decreasing). For example, the signature of the permutation {3,1,2,7,4,6,5} is \"DIIDID\".\u003cbr\u003e\u003cbr\u003eYour task is as follows: You are given a string describing the signature of many possible permutations, find out how many permutations satisfy this signature.\u003cbr\u003e\u003cbr\u003eNote: For any positive integer n, a permutation of n elements is a sequence of length n that contains each of the integers 1 through n exactly once.\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"Each test case consists of a string of 1 to 1000 characters long, containing only the letters \u0027I\u0027, \u0027D\u0027 or \u0027?\u0027, representing a permutation signature.\u003cbr\u003e\u003cbr\u003eEach test case occupies exactly one single line, without leading or trailing spaces.\u003cbr\u003e\u003cbr\u003eProceed to the end of file. The \u0027?\u0027 in these strings can be either \u0027I\u0027 or \u0027D\u0027.\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, print the number of permutations satisfying the signature on a single line. In case the result is too large, print the remainder modulo 1000000007.\u003cbr\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003eII\r\nID\r\nDI\r\nDD\r\n?D\r\n??\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\n2\r\n2\r\n1\r\n3\r\n6\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cbr\u003ePermutation {1,2,3} has signature \"II\".\u003cbr\u003ePermutations {1,3,2} and {2,3,1} have signature \"ID\".\u003cbr\u003ePermutations {3,1,2} and {2,1,3} have signature \"DI\".\u003cbr\u003ePermutation {3,2,1} has signature \"DD\".\u003cbr\u003e\"?D\" can be either \"ID\" or \"DD\".\u003cbr\u003e\"??\" gives all possible permutations of length 3.\u003cbr\u003e"}}]}