#include<bits/stdc++.h>
#define N 100005
#define Ms(a,b) memset(a,b,sizeof a)
#define db(x) cerr<<#x<<"="<<x<<endl;
#define db2(x,y) cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define db3(x,y,z) cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
using namespace std;
int rd(){
    int res=0,c,f=0;
    while(!isdigit(c=getchar()))f=c=='-';
    do res=(res<<1)+(res<<3)+(c^48);
    while(isdigit(c=getchar()));
    return f?-res:res;
}
int n;
int main(){
    n=rd();
    for(int i=1;i<=n;i++){
        int t=0,x=i;
        for(int j=2;1ll*j*j<=x;j++)while(x%j==0)x/=j,++t;
        if(x!=1)++t;
        printf("%d%c",t+1," \n"[i==n]);
    }
    return 0;
}


#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "queue"
using namespace std;
#define MAXN 600006
//#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define all(x) (x).begin() , (x).end()
#define mem( a ) memset( a , 0 , sizeof a )
typedef long long ll;
int n , m;
char aa , ab , ba , bb;
const int P = 1e9 + 7;
void solve() {
	cin >> n;
	if( n <= 2 ) { puts("1"); return; }
	char ch[4];
	scanf("%s",ch); aa = ch[0];
	scanf("%s",ch); ab = ch[0];
	scanf("%s",ch); ba = ch[0];
	scanf("%s",ch); bb = ch[0];
	static int p2[MAXN] , F[MAXN];
	p2[0] = 1;
	rep( i , 1 , n ) p2[i] = p2[i - 1] * 2 % P;
	F[0] = F[1] = 1;
	rep( i , 2 , n ) F[i] = ( F[i - 1] + F[i - 2] ) % P;
	if( ab == 'B' ) {
		if( bb == 'B' ) return void( puts("1") );
		if( ba == 'A' ) return void( cout << p2[n - 3] << endl );
		cout << F[n - 2] << endl;
	} else {
		if( aa == 'A' ) return void( puts("1") );
		if( ba == 'B' ) return void( cout << p2[n - 3] << endl );
		cout << F[n - 2] << endl;
	}
}

signed main() {
//	freopen("5.in","r",stdin);
//	int T;cin >> T;while( T-- ) solve();
	solve();
}

