{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n section pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"Problem Statement","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003eWe have a board with a \u003cvar\u003e\\(2 \\times N\\)\u003c/var\u003e grid.\r\nSnuke covered the board with \u003cvar\u003e\\(N\\)\u003c/var\u003e dominoes without overlaps.\r\nHere, a domino can cover a \u003cvar\u003e\\(1 \\times 2\\)\u003c/var\u003e or \u003cvar\u003e\\(2 \\times 1\\)\u003c/var\u003e square.\u003c/p\u003e\r\n\u003cp\u003eThen, Snuke decided to paint these dominoes using three colors: red, cyan and green.\r\nTwo dominoes that are adjacent by side should be painted by different colors.\r\nHere, it is not always necessary to use all three colors.\u003c/p\u003e\r\n\u003cp\u003eFind the number of such ways to paint the dominoes, modulo \u003cvar\u003e\\(1000000007\\)\u003c/var\u003e.\u003c/p\u003e\r\n\u003cp\u003eThe arrangement of the dominoes is given to you as two strings \u003cvar\u003e\\(S_1\\)\u003c/var\u003e and \u003cvar\u003e\\(S_2\\)\u003c/var\u003e in the following manner:\u003c/p\u003e\r\n\u003cul\u003e\r\n\u003cli\u003eEach domino is represented by a different English letter (lowercase or uppercase).\u003c/li\u003e\r\n\u003cli\u003eThe \u003cvar\u003e\\(j\\)\u003c/var\u003e-th character in \u003cvar\u003e\\(S_i\\)\u003c/var\u003e represents the domino that occupies the square at the \u003cvar\u003e\\(i\\)\u003c/var\u003e-th row from the top and \u003cvar\u003e\\(j\\)\u003c/var\u003e-th column from the left.\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Constraints","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cul\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(1 \\leq N \\leq 52\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(|S_1| \u003d |S_2| \u003d N\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(S_1\\)\u003c/var\u003e and \u003cvar\u003e\\(S_2\\)\u003c/var\u003e consist of lowercase and uppercase English letters.\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(S_1\\)\u003c/var\u003e and \u003cvar\u003e\\(S_2\\)\u003c/var\u003e represent a valid arrangement of dominoes.\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Input","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003eInput is given from Standard Input in the following format:\u003c/p\u003e\r\n\u003cpre\u003e\u003cvar\u003e\\(N\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(S_1\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(S_2\\)\u003c/var\u003e\r\n\u003c/pre\u003e\r\n\r\n\u003c/section\u003e\r\n"}},{"title":"Output","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003ePrint the number of such ways to paint the dominoes, modulo \u003cvar\u003e\\(1000000007\\)\u003c/var\u003e.\u003c/p\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 1","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\u003e3\r\naab\r\nccb\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e6\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003cp\u003eThere are six ways as shown below:\u003c/p\u003e\r\n\u003cp\u003e\u003cimg alt\u003d\"\" src\u003d\"CDN_BASE_URL/e81d2bc3c9dcb0a6a6e4b2b87f3f7377?v\u003d1715590585\"\u003e\u003c/p\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 2","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\u003e1\r\nZ\r\nZ\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003cp\u003eNote that it is not always necessary to use all the colors.\u003c/p\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 3","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\u003e52\r\nRvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn\r\nRLLwwdWIxxNNQUUXXVVMMooBBaggDKqcimmeYrhAljOOTTJuuzzn\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e958681902\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\u003c/section\u003e\r\n"}}]}