#include<bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	int n=gi();
	char caa,cab,cba,cbb;
	caa=getchar();getchar();
	cab=getchar();getchar();
	cba=getchar();getchar();
	cbb=getchar();getchar();
	if(cab=='B'){
		std::swap(caa,cbb);
		caa=((caa-'A')^1)+'A';
		cba=((cba-'A')^1)+'A';
		cab=((cab-'A')^1)+'A';
	}
	if(caa=='A')puts("1");
	else if(cba=='B')printf("%d\n",n==2?1:pow(2,n-3));
	else{
		int f[1010]={1,1};
		for(int i=2;i<=n;++i)f[i]=(f[i-1]+f[i-2])%mod;
		printf("%d\n",f[n-2]);
	}
	return 0;
}

//yukicoder@cpp14
//coder:luckYrat(twitter:@luckYrat_)
//dijkstraから逃げるな
//おすすめの曲
//https://soundcloud.com/nagiha/alice-in-a-xxxxxxxx
//https://soundcloud.com/synthion/sweetheart

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define mkp make_pair
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {mkp(0,1),mkp(0,-1),mkp(1,0),mkp(-1,0)};
P ar8[8] = {mkp(-1,-1),mkp(-1,0),mkp(-1,1),mkp(0,-1),mkp(0,1),mkp(1,-1),mkp(1,0),mkp(1,1)};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int a,b,c;cin>>a>>b>>c;
  if(c%2){
    if(a>b){
      cout << ">" << endl;
    }else if(a<b){
      cout << "<" << endl;
    }else{
      cout << "=" << endl;
    }
  }else{
    if(abs(a)==abs(b)){
      cout << "=" << endl;
    }else if(abs(a)>abs(b)){
      cout << ">" << endl;
    }else{
      cout << "<" << endl;
    }
  }
  return 0;
}