{"problem":{"name":"Coloring Dominoes","description":{"content":"We have a board with a $2 \\times N$ grid. Snuke covered the board with $N$ dominoes without overlaps. Here, a domino can cover a $1 \\times 2$ or $2 \\times 1$ square. Then, Snuke decided to paint these","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc081_b"},"statements":[{"statement_type":"Markdown","content":"We have a board with a $2 \\times N$ grid. Snuke covered the board with $N$ dominoes without overlaps. Here, a domino can cover a $1 \\times 2$ or $2 \\times 1$ square.\nThen, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two dominoes that are adjacent by side should be painted by different colors. Here, it is not always necessary to use all three colors.\nFind the number of such ways to paint the dominoes, modulo $1000000007$.\nThe arrangement of the dominoes is given to you as two strings $S_1$ and $S_2$ in the following manner:\n\n*   Each domino is represented by a different English letter (lowercase or uppercase).\n*   The $j$\\-th character in $S_i$ represents the domino that occupies the square at the $i$\\-th row from the top and $j$\\-th column from the left.\n\n## Constraints\n\n*   $1 \\leq N \\leq 52$\n*   $|S_1| = |S_2| = N$\n*   $S_1$ and $S_2$ consist of lowercase and uppercase English letters.\n*   $S_1$ and $S_2$ represent a valid arrangement of dominoes.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$S_1$\n$S_2$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc081_b","tags":[],"sample_group":[["3\naab\nccb","6\n\nThere are six ways as shown below:\n![image](https://atcoder.jp/img/arc081/899673bd23529f4fb5e41c6e7d5bc372.png)"],["1\nZ\nZ","3\n\nNote that it is not always necessary to use all the colors."],["52\nRvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn\nRLLwwdWIxxNNQUUXXVVMMooBBaggDKqcimmeYrhAljOOTTJuuzzn","958681902"]],"created_at":"2026-03-03 11:01:13"}}