{"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\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","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 \u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027]], displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027]]}\n });\n \u003c/script\u003e\n \u003cscript type\u003d\"text/javascript\" async\n src\u003d\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\"\u003e\n \u003c/script\u003e\n\u003cp\u003eYou are given a string $$$s$$$ consisting of lowercase Latin letters \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ea\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eb\u003c/span\u003e\" and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ec\u003c/span\u003e\" and question marks \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e?\u003c/span\u003e\".\u003c/p\u003e\n\u003cp\u003eLet the number of question marks in the string $$$s$$$ be $$$k$$$. Let\u0027s replace each question mark with one of the letters \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ea\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eb\u003c/span\u003e\" and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ec\u003c/span\u003e\". Here we can obtain all $$$3^{k}$$$ possible strings consisting only of letters \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ea\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eb\u003c/span\u003e\" and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ec\u003c/span\u003e\". For example, if $$$s \u003d $$$\"\u003cspan class\u003d\"tex-font-style-tt\"\u003eac?b?c\u003c/span\u003e\" then we can obtain the following strings: $$$[$$$\"\u003cspan class\u003d\"tex-font-style-tt\"\u003eacabac\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eacabbc\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eacabcc\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eacbbac\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eacbbbc\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eacbbcc\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eaccbac\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eaccbbc\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eaccbcc\u003c/span\u003e\"$$$]$$$.\u003c/p\u003e\n\u003cp\u003eYour task is to count the total number of subsequences \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eabc\u003c/span\u003e\" in all resulting strings. Since the answer can be very large, print it modulo $$$10^{9} + 7$$$.\u003c/p\u003e\n\u003cp\u003eA subsequence of the string $$$t$$$ is such a sequence that can be derived from the string $$$t$$$ after removing some (possibly, zero) number of letters without changing the order of remaining letters. For example, the string \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ebaacbc\u003c/span\u003e\" contains two subsequences \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eabc\u003c/span\u003e\" — a subsequence consisting of letters at positions $$$(2, 5, 6)$$$ and a subsequence consisting of letters at positions $$$(3, 5, 6)$$$.\u003c/p\u003e\n题意\u003cbr\u003e\n给出一个长度为 n (3≤n≤200000)的字符串,由 \u0027 a \u0027 , \u0027 b \u0027 , \u0027 c \u0027 和 \u0027 ? \u0027 组成,每一个 \u0027 ? \u0027 都可以变成三个字母之一,这样的话假设有 k 个 \u0027 ? \u0027 ,则整个字符串就有 3^k 中不同的表示,现在问这 3^k 个字符串中,一共有多少个 abc 的子序列,结果对 10^9 +7 取模 \u003cbr\u003e\n概念区分:\u003cbr\u003e\n子序列:不需要连续\u003cbr\u003e\n子串:需要连续\n\u003cbr\u003e\n翻译:https://www.luogu.com.cn/problem/CF1426F"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line of the input contains one integer $$$n$$$ $$$(3 \\le n \\le 200\\,000)$$$ — the length of $$$s$$$.\u003c/p\u003e\n\u003cp\u003eThe second line of the input contains the string $$$s$$$ of length $$$n$$$ consisting of lowercase Latin letters \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ea\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eb\u003c/span\u003e\" and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ec\u003c/span\u003e\" and question marks\"\u003cspan class\u003d\"tex-font-style-tt\"\u003e?\u003c/span\u003e\".\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003ePrint the total number of subsequences \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eabc\u003c/span\u003e\" in all strings you can obtain if you replace all question marks with letters \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ea\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eb\u003c/span\u003e\" and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ec\u003c/span\u003e\", modulo $$$10^{9} + 7$$$.\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\u003e6\nac?b?c\n\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\u003e24\n\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\u003e7\n???????\n\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\u003e2835\n\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\u003e9\ncccbbbaaa\n\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\u003e0\n\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\u003e5\na???c\n\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\u003e46\n\u003c/pre\u003e\n \u003c/div\u003e\n\u003c/div\u003e"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the first example, we can obtain $$$9$$$ strings:\u003c/p\u003e\n\u003cul\u003e \n \u003cli\u003e \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eacabac\u003c/span\u003e\" — there are $$$2$$$ subsequences \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eabc\u003c/span\u003e\", \u003c/li\u003e\n \u003cli\u003e \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eacabbc\u003c/span\u003e\" — there are $$$4$$$ subsequences \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eabc\u003c/span\u003e\", \u003c/li\u003e\n \u003cli\u003e \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eacabcc\u003c/span\u003e\" — there are $$$4$$$ subsequences \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eabc\u003c/span\u003e\", \u003c/li\u003e\n \u003cli\u003e \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eacbbac\u003c/span\u003e\" — there are $$$2$$$ subsequences \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eabc\u003c/span\u003e\", \u003c/li\u003e\n \u003cli\u003e \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eacbbbc\u003c/span\u003e\" — there are $$$3$$$ subsequences \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eabc\u003c/span\u003e\", \u003c/li\u003e\n \u003cli\u003e \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eacbbcc\u003c/span\u003e\" — there are $$$4$$$ subsequences \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eabc\u003c/span\u003e\", \u003c/li\u003e\n \u003cli\u003e \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eaccbac\u003c/span\u003e\" — there is $$$1$$$ subsequence \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eabc\u003c/span\u003e\", \u003c/li\u003e\n \u003cli\u003e \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eaccbbc\u003c/span\u003e\" — there are $$$2$$$ subsequences \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eabc\u003c/span\u003e\", \u003c/li\u003e\n \u003cli\u003e \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eaccbcc\u003c/span\u003e\" — there are $$$2$$$ subsequences \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eabc\u003c/span\u003e\". \u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eSo, there are $$$2 + 4 + 4 + 2 + 3 + 4 + 1 + 2 + 2 \u003d 24$$$ subsequences \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eabc\u003c/span\u003e\" in total.\u003c/p\u003e"}}]}