You are given a string s consisting of lowercase Latin letters "a", "b" and "c" and question marks "?".

Let the number of question marks in the string s be k. Let's replace each question mark with one of the letters "a", "b" and "c". Here we can obtain all 3^{k} possible strings consisting only of letters "a", "b" and "c". For example, if s = "ac?b?c" then we can obtain the following strings: ["acabac", "acabbc", "acabcc", "acbbac", "acbbbc", "acbbcc", "accbac", "accbbc", "accbcc"].

Your task is to count the total number of subsequences "abc" in all resulting strings. Since the answer can be very large, print it modulo 10^{9} + 7.

A subsequence of the string t is such a sequence that can be derived from the string t after removing some (possibly, zero) number of letters without changing the order of remaining letters. For example, the string "baacbc" contains two subsequences "abc" — a subsequence consisting of letters at positions (2, 5, 6) and a subsequence consisting of letters at positions (3, 5, 6).

Input

The first line of the input contains one integer n (3 ≤ n ≤ 200 000) — the length of s.

The second line of the input contains the string s of length n consisting of lowercase Latin letters "a", "b" and "c" and question marks"?".

Output

Print the total number of subsequences "abc" in all strings you can obtain if you replace all question marks with letters "a", "b" and "c", modulo 10^{9} + 7.

Examples

Input


6
ac?b?c


Output


24


Input


7
???????


Output


2835


Input


9
cccbbbaaa


Output


0


Input


5
a???c


Output


46

Note

In the first example, we can obtain 9 strings:

  * "acabac" — there are 2 subsequences "abc", 
  * "acabbc" — there are 4 subsequences "abc", 
  * "acabcc" — there are 4 subsequences "abc", 
  * "acbbac" — there are 2 subsequences "abc", 
  * "acbbbc" — there are 3 subsequences "abc", 
  * "acbbcc" — there are 4 subsequences "abc", 
  * "accbac" — there is 1 subsequence "abc", 
  * "accbbc" — there are 2 subsequences "abc", 
  * "accbcc" — there are 2 subsequences "abc". 



So, there are 2 + 4 + 4 + 2 + 3 + 4 + 1 + 2 + 2 = 24 subsequences "abc" in total.
import java.util.*;
import java.io.*;

public class F674 {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt();
        int [] a = new int[n];
        String s = sc.next();
        long [][] pref = new long[n][3];
        long [] q = new long[n];
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == '?') a[i] = -1;
            else a[i] = s.charAt(i) - 'a';
        }
        if (a[0] != -1) pref[0][a[0]] = 1;
        for (int i = 1; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                pref[i][j] = pref[i - 1][j];
                if (a[i] == j) pref[i][j]++;
            }
        }
        if (a[0] == -1) q[0] = 1;
        for (int i = 1; i < n; i++) q[i] = q[i - 1] + (a[i] == -1 ? 1 : 0);
        //initFac(n + 3);
        long [][] dp = new long[n][3];
        if (a[0] == 0) dp[0][0] = 1;
        for (int i = 1; i < n; i++) {
            if (a[i] == -1) {
                dp[i][0] = dp[i - 1][0];
                dp[i][1] = dp[i - 1][1];
                dp[i][2] = dp[i - 1][2];
            } else if (a[i] == 0) {
                dp[i][0] = (dp[i - 1][0] + 1) % mod;
                dp[i][1] = dp[i - 1][1];
                dp[i][2] = dp[i - 1][2];
            } else if (a[i] == 1) {
                dp[i][0] = dp[i - 1][0];
                dp[i][1] = (dp[i - 1][1] + dp[i - 1][0]) % mod;
                dp[i][2] = dp[i - 1][2];
            } else {
                dp[i][0] = dp[i - 1][0];
                dp[i][1] = dp[i - 1][1];
                dp[i][2] = (dp[i - 1][2] + dp[i - 1][1]) % mod;
            }
        }
        long [][] dp2 = new long[n][3];
        if (a[n - 1] == 2) dp2[n - 1][2] = 1;
        for (int i = n - 2; i >= 0; i--) {
            if (a[i] == -1 || a[i] == 0) {
                dp2[i][2] = dp2[i + 1][2];
                dp2[i][1] = dp2[i + 1][1];
            } else if (a[i] == 1) {
                dp2[i][1] = (dp2[i + 1][1] + dp2[i + 1][2]) % mod;
                dp2[i][2] = dp2[i + 1][2];
            } else {
                dp2[i][1] = dp2[i + 1][1];
                dp2[i][2] = dp2[i + 1][2] + 1;
            }
        }
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] == -1) count++;
        }
        long ans = (dp[n - 1][2] * ((pow(3, count)) % mod)) % mod;
        initFac(n + 3);
        // all 3 ?
        if (count >= 3) {
            ans = (ans + ((nck(count, 3) * pow(3, count - 3)) % mod)) % mod;
        }
        // 2 ?s
        if (count >= 2) {
            for (int i = 0; i < n; i++) {
                if (a[i] == 0) {
                    long after = nck((int) (q[n - 1] - q[i]), 2) % mod;
                    ans = (ans + ((after * pow(3, count - 2)) % mod)) % mod;
                } else if (a[i] == 1) {
                    long mid = (q[i] * (q[n - 1] - q[i])) % mod;
                    ans = (ans + ((mid * pow(3, count - 2)) % mod)) % mod;
                } else if (a[i] == 2) {
                    long before = nck((int) q[i], 2) % mod;
                    ans = (ans + ((before * pow(3, count - 2)) % mod)) % mod;
                }
            }
        }
        // 1 ?s
        if (count >= 1) {
            for (int i = 0; i < n; i++) {
                if (a[i] == -1) {
                    ans = (ans + ((dp[i][1] * pow(3, count - 1)) % mod)) % mod;
                    long aBefore = pref[i][0];
                    long cAfter = pref[n - 1][2] - pref[i][2];
                    long p = (aBefore * cAfter) % mod;
                    ans = (ans + ((p * pow(3, count - 1)) % mod)) % mod;
                    ans = (ans + ((dp2[i][1] * pow(3, count - 1)) % mod)) % mod;
                }
            }
        }
        ans %= mod;
        if (ans < 0) ans += mod;
        out.println(ans);
        out.close();
    }

    static long[] fac;
    static long mod = (long) 1e9 + 7;

    static void initFac(long n) {
        fac = new long[(int)n + 1];
        fac[0] = 1;
        for (int i = 1; i <= n; i++) {
            fac[i] = (fac[i - 1]  * i) % mod;
        }
    }



    static long nck(int n, int k) {
        if (n < k)
            return 0;
        long den = inv((int) (fac[k] * fac[n - k] % mod));
        return fac[n] * den % mod;
    }

    static long pow(long b, long e) {
        long ans = 1;
        while (e > 0) {
            if (e % 2 == 1)
                ans = ans * b % mod;
            e >>= 1;
            b = b * b % mod;
        }
        return ans;
    }

    static long inv(long x) {
        return pow(x, mod - 2);
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}