#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

/*
    実行時MODint :
    template <int& MOD = 1000000007>
    static int MOD;
    cin >> MOD;
*/
template <int MOD = 1000000007>
struct Mint {
    int x;

    constexpr Mint() : x(0) {}
    constexpr Mint(long long t)
        : x(t >= 0 ? (t % MOD) : (MOD - (-t) % MOD) % MOD) {}

    Mint pow(int n) {
        Mint res(1), t(x);
        while (n > 0) {
            if (n & 1) res *= t;
            t *= t;
            n >>= 1;
        }
        return res;
    }

    Mint inv() const {
        int a = x, b = MOD, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return Mint(u);
    }

    Mint &operator+=(Mint a) {
        x += a.x;
        if (x >= MOD) x -= MOD;
        return *this;
    }

    Mint &operator-=(Mint a) {
        x += MOD - a.x;
        if (x >= MOD) x -= MOD;
        return *this;
    }

    Mint &operator*=(Mint a) {
        x = int(1LL * x * a.x % MOD);
        return *this;
    }

    Mint &operator/=(Mint a) {
        return (*this) *= a.inv();
    }

    Mint operator+(Mint a) const {
        return Mint(x) += a;
    }
    Mint operator-(Mint a) const {
        return Mint(x) -= a;
    }
    Mint operator*(Mint a) const {
        return Mint(x) *= a;
    }
    Mint operator/(Mint a) const {
        return Mint(x) /= a;
    }

    Mint operator-() const {
        return Mint(-x);
    }

    bool operator==(const Mint a) {
        return x == a.x;
    }
    bool operator!=(const Mint a) {
        return x != a.x;
    }
    bool operator<(const Mint a) {
        return x < a.x;
    }

    friend ostream &operator<<(ostream &os, const Mint &a) {
        return os << a.x;
    }

    friend istream &operator>>(istream &is, Mint &a) {
        int t;
        is >> t;
        a = Mint<MOD>(t);
        return (is);
    }
};

signed main() {
    int n;
    cin >> n;
    char caa, cab, cba, cbb;
    cin >> caa >> cab >> cba >> cbb;
    if (n <= 3) {
        cout << 1 << endl;
        return 0;
    }
    if ((cab == 'A' && caa == 'A') || (cab == 'B' && cbb == 'B')) {
        cout << 1 << endl;
        return 0;
    }
    if ((cab == 'A' && caa == 'B' && cba == 'A') ||
        (cab == 'B' && cbb == 'A' && cba == 'B')) {
        Mint<> dp[n][2];
        dp[0][0] = 1;
        rep(i, n - 1) {
            dp[i + 1][0] += dp[i][1];
            dp[i + 1][1] += (dp[i][0] + dp[i][1]);
        }
        cout << dp[n - 1][1] << endl;
        return 0;
    }
    cout << Mint<>(2).pow(n - 3) << endl;
    return 0;
}
/**

    template for testing/using the algorithms

    import(copy-paste the methods ;v) algorithm/s and use here

**/

#include <iostream>
#include <bits/stdc++.h>

using namespace std;


///------------------- algorithm function/s to be placed here start -------------------///

bool isEqual(double a, double b){

    double EPS = 1e-9;

    return abs(a-b) <= EPS;
}

double slope(double x1, double y1, double x2, double y2){

    if((x2-x1)==0) return -1;

    return (y2-y1)/(x2-x1);

}

bool isOnTheSameLine(int x1, int y1, int x2, int y2, int x3, int y3){

    return  (x1-x2)*(y1-y3) == (y1-y2)*(x1-x3);

}

///------------------- algorithm function/s to be placed here end -------------------///


void simulate(){
// simulate input to test the algorithm being implemented
}


int getRandomNumberInRange(int lower, int upper){
// generate a random number in the range- ['lower', 'upper']
    srand(time(0));
    return rand()%(upper-lower+1)+lower;
}


void exec(int T){
// execute the algorithm

    int n;

    cin>>n;

    vector<pair<int, int>> points;

    while(n--){
        int a,b;
        cin>>a>>b;
        points.push_back({a,b});
    }

    bool yes = false;

    for(int i=0;i<points.size();i++){
        for(int j=i+1;j<points.size();j++){

            pair<int, int> p1=points[i],p2=points[j];

            for(int k=j+1;k<points.size();k++){

                pair<int, int> p3 = points[k];

                if( isOnTheSameLine(p1.first, p1.second, p2.first, p2.second, p3.first, p3.second) ){

                    yes=true;
                    break;
                }

            }

            /*
            slopeCnt[ slopeP1P2 ]++;

            if(slopeCnt[slopeP1P2]>=2){
                yes = true;
                break;
            */
        }
        if(yes) break;
    }

    if(yes) cout<<"Yes\n";
    else cout<<"No\n";

}


int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int t=1;

    //cin>>t;

    for(int T=1;T<=t;T++){

        exec(T);

    }

    return 0;
}
