func_code_string: #include <bits/stdc++.h>   using namespace std;   long long numC[200011];   long long numQ[200011];   long long numBC[200011];   long long numBQ[200011];   long long numQC[200011];   long long numQQ[200011];   long long triple(int n) {     if (n < 0) return 0;     if (n == 1) return 3;     if (n == 0) return 1;     long long temp = triple(n / 2);     long long res = (temp * temp) % 1000000007;     if (n % 2 == 0)       return res;     else       return (res * 3) % 1000000007;   }   int main() {     int n;     string str;     cin >> n >> str;     int qNum = 0;     for (int i = 0; i < n; i++)       if (str[i] ==  ? ) qNum++;     for (int i = n - 1; i >= 0; i--) {       if (str[i] ==  c )         numC[i] = numC[i + 1] + 1;       else         numC[i] = numC[i + 1];     }     for (int i = n - 1; i >= 0; i--) {       if (str[i] ==  ? )         numQ[i] = numQ[i + 1] + 1;       else         numQ[i] = numQ[i + 1];     }     for (int i = n - 1; i >= 0; i--) {       if (str[i] ==  b )         numBC[i] = numBC[i + 1] + numC[i + 1];       else         numBC[i] = numBC[i + 1];       numBC[i] %= 1000000007;     }     for (int i = n - 1; i >= 0; i--) {       if (str[i] ==  b )         numBQ[i] = numBQ[i + 1] + numQ[i + 1];       else         numBQ[i] = numBQ[i + 1];       numBQ[i] %= 1000000007;     }     for (int i = n - 1; i >= 0; i--) {       if (str[i] ==  ? )         numQC[i] = numQC[i + 1] + numC[i + 1];       else         numQC[i] = numQC[i + 1];       numQC[i] %= 1000000007;     }     for (int i = n - 1; i >= 0; i--) {       if (str[i] ==  ? )         numQQ[i] = numQQ[i + 1] + numQ[i + 1];       else         numQQ[i] = numQQ[i + 1];       numQQ[i] %= 1000000007;     }     long long t1 = 0;     for (int i = n - 1; i >= 0; i--)       if (str[i] ==  a ) t1 += numBC[i + 1];     t1 %= 1000000007;     long long t2 = 0;     for (int i = n - 1; i >= 0; i--)       if (str[i] ==  a ) t2 += numQC[i + 1];     for (int i = n - 1; i >= 0; i--)       if (str[i] ==  a ) t2 += numBQ[i + 1];     for (int i = n - 1; i >= 0; i--)       if (str[i] ==  ? ) t2 += numBC[i + 1];     t2 %= 1000000007;     long long t3 = 0;     for (int i = n - 1; i >= 0; i--)       if (str[i] ==  a ) t3 += numQQ[i + 1];     for (int i = n - 1; i >= 0; i--)       if (str[i] ==  ? ) t3 += numBQ[i + 1];     for (int i = n - 1; i >= 0; i--)       if (str[i] ==  ? ) t3 += numQC[i + 1];     t3 %= 1000000007;     long long t4 = 0;     for (int i = n - 1; i >= 0; i--)       if (str[i] ==  ? ) t4 += numQQ[i + 1];     t4 %= 1000000007;     long long ans = (t1 * triple(qNum)) % 1000000007 +                     (t2 * triple(qNum - 1)) % 1000000007 +                     (t3 * triple(qNum - 2)) % 1000000007 +                     (t4 * triple(qNum - 3)) % 1000000007;     cout << ans % 1000000007;   }   