#include <bits/stdc++.h>   int main() {     int n, i;     long long cnt[5] = {0};     char ch;     scanf( %d , &n);     getchar();     cnt[0] = 1;     for (i = 0; i < n; i++) {       scanf( %c , &ch);       if (ch ==  a ) {         cnt[1] = (cnt[1] + cnt[0]) % 1000000007;       } else if (ch ==  b ) {         cnt[2] = (cnt[2] + cnt[1]) % 1000000007;       } else if (ch ==  c ) {         cnt[3] = (cnt[3] + cnt[2]) % 1000000007;       } else if (ch ==  ? ) {         cnt[3] = (3 * cnt[3] % 1000000007 + cnt[2]) % 1000000007;         cnt[2] = (3 * cnt[2] % 1000000007 + cnt[1]) % 1000000007;         cnt[1] = (3 * cnt[1] % 1000000007 + cnt[0]) % 1000000007;         cnt[0] = 3 * cnt[0] % 1000000007;       }     }     printf( %lld n , cnt[3]);     return 0;   }   