{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\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 type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cstyle type\u003d\u0027text/css\u0027\u003e .input, .output {border: 1px solid #888888;} .output {margin-bottom:1em;position:relative;top:-1px;} .output pre,.input pre {background-color:#EFEFEF;line-height:1.25em;margin:0;padding:0.25em;} .title {background-color:#FFFFFF;border-bottom: 1px solid #888888;font-family:arial;font-weight:bold;padding:0.25em;} \u003c/style\u003e\u003cp\u003eOnce Petya read a problem about a bracket sequence. He gave it much thought but didn\u0027t find a solution. Today you will face it.\u003c/p\u003e\n\n\n\u003cp\u003e有一个字符串 \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e\u003c/span\u003e. 这个字符串是一个完全匹配的括号序列. A correct bracket sequence is the sequence of opening (\"\u003cspan class\u003d\"tex-font-style-tt\"\u003e(\u003c/span\u003e\") and closing (\"\u003cspan class\u003d\"tex-font-style-tt\"\u003e)\u003c/span\u003e\") brackets, such that it is possible to obtain a correct mathematical expression from it, inserting numbers and operators between the brackets. For example, such sequences as \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e(())()\u003c/span\u003e\" and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e()\u003c/span\u003e\" are correct bracket sequences and such sequences as \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e)()\u003c/span\u003e\" and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e(()\u003c/span\u003e\" are not.\u003c/p\u003e\n\n\n\u003cp\u003e在这个完全匹配的括号序列里,每个括号都有一个和它匹配的括号 (an opening bracket corresponds to the matching closing bracket and vice versa). For example, in a bracket sequence shown of the figure below, the third bracket corresponds to the matching sixth one and the fifth bracket corresponds to the fourth one.\u003c/p\u003e\n\n\n\u003ccenter\u003e \n \u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/5ecc7ac9485b3eb8d655570a5ff3d9be?v\u003d1522979022\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\" SRC\u003d\"CDN_BASE_URL/5ecc7ac9485b3eb8d655570a5ff3d9be?v\u003d1522979022\"\u003e \n\u003c/center\u003e \n\n\n\u003cp\u003e你现在可以给这个匹配的括号序列中的括号染色,且有三个要求: \u003c/p\u003e\n\u003cul\u003e \n \u003cli\u003e 每个括号只有三种情况,不上色,上红色,上蓝色. \u003c/li\u003e\n \u003cli\u003e 每对括号必须只能给其中的一个上色,且必须给一个上色;For any pair of matching brackets exactly one of them is colored. In other words, for any bracket the following is true: either it or the matching bracket that corresponds to it is colored. \u003c/li\u003e\n \u003cli\u003e 相邻的两个不能上同色,可以都不上色;No two neighboring colored brackets have the same color. \u003c/li\u003e\n\u003c/ul\u003e\n\n求满足条件的括号序列染色的方法数, 这个数值会比较大,只需要 mod \u003cspan class\u003d\"tex-span\"\u003e1000000007\u003c/span\u003e (\u003cspan class\u003d\"tex-span\"\u003e10\u003csup class\u003d\"upper-index\"\u003e9\u003c/sup\u003e + 7\u003c/span\u003e).\u003c/p\u003e\n\u003cp\u003eFind the number of different ways to color the bracket sequence. The ways should meet the above-given conditions. Two ways of coloring are considered different if they differ in the color of at least one bracket. As the result can be quite large, print it modulo \u003cspan class\u003d\"tex-span\"\u003e1000000007\u003c/span\u003e (\u003cspan class\u003d\"tex-span\"\u003e10\u003csup class\u003d\"upper-index\"\u003e9\u003c/sup\u003e + 7\u003c/span\u003e).\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains the single string \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003es\u003c/i\u003e\u003c/span\u003e (\u003cspan class\u003d\"tex-span\"\u003e2 ≤ |\u003ci\u003es\u003c/i\u003e| ≤ 700\u003c/span\u003e) which represents a correct bracket sequence. \u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003ePrint the only number — the number of ways to color the bracket sequence that meet the above given conditions modulo \u003cspan class\u003d\"tex-span\"\u003e1000000007\u003c/span\u003e (\u003cspan class\u003d\"tex-span\"\u003e10\u003csup class\u003d\"upper-index\"\u003e9\u003c/sup\u003e + 7\u003c/span\u003e).\u003c/p\u003e"}},{"title":"Examples","value":{"format":"HTML","content":"\u003cdiv class\u003d\"sample-test\"\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e(())\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e12\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e(()())\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e40\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e()\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e4\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n\u003c/div\u003e"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eLet\u0027s consider the first sample test. The bracket sequence from the sample can be colored, for example, as is shown on two figures below. \u003c/p\u003e\n\u003ccenter\u003e \n \u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/507e467342fff155c446f120833ab5a0?v\u003d1522979022\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\" SRC\u003d\"CDN_BASE_URL/507e467342fff155c446f120833ab5a0?v\u003d1522979022\"\u003e \n \u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/d2972a72f8abe4cd489233b7ac25cfc5?v\u003d1522979022\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\" SRC\u003d\"CDN_BASE_URL/d2972a72f8abe4cd489233b7ac25cfc5?v\u003d1522979022\"\u003e \n\u003c/center\u003e \n\u003cp\u003eThe two ways of coloring shown below are incorrect. \u003c/p\u003e\n\u003ccenter\u003e \n \u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/3f2ce97412d636bbbf84bdad2b712d02?v\u003d1522979022\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\" SRC\u003d\"CDN_BASE_URL/3f2ce97412d636bbbf84bdad2b712d02?v\u003d1522979022\"\u003e \n \u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/ce8c116ac86506c352c32964b47acad1?v\u003d1522979022\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\" SRC\u003d\"CDN_BASE_URL/ce8c116ac86506c352c32964b47acad1?v\u003d1522979022\"\u003e \n\u003c/center\u003e"}}]}