func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 200005, P = 1e9 + 7;   int dp[N][3], val[3], n;   int add(int a, int b) { return (a += b) >= P ? a - P : a; }   int qpow(int a, int b) {     int res = 1;     while (b) {       if (b & 1) res = 1ll * res * a % P;       a = 1ll * a * a % P;       b >>= 1;     }     return res;   }   int main() {     string s;     cin >> n >> s;     s =  %  + s;     int qs = count(s.begin(), s.end(),  ? );     const int f3 = qpow(3, qs), inv3 = qpow(3, P - 2);     for (int i = 1; i <= n; ++i) {       if (s[i] ==  a ) {         dp[i][1] = dp[i][2] = 0;         dp[i][0] = 1;         val[0] = add(val[0], 1);       } else if (s[i] ==  b ) {         dp[i][0] = dp[i][2] = 0;         dp[i][1] = val[0];         val[1] = add(val[1], dp[i][1]);       } else if (s[i] ==  c ) {         dp[i][0] = dp[i][1] = 0;         dp[i][2] = val[1];         val[2] = add(val[2], dp[i][2]);       } else {         dp[i][0] = inv3;         dp[i][1] = (long long)inv3 * val[0] % P;         dp[i][2] = (long long)inv3 * val[1] % P;         val[0] = add(val[0], inv3);         val[1] = add(val[1], dp[i][1]);         val[2] = add(val[2], dp[i][2]);       }     }     cout << (long long)val[2] * f3 % P <<   n ;     return 0;   }   