#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }
int n,ans[11];
const int P = 1e9+  7;
char caa,cab,cba,cbb;
unordered_map<string,int>mp;
inline void dfs(string s){
	if (mp.count(s)) return;
	++ans[s.size()]; 
	mp[s] = 1; if (s.size() ==10){ return; }
	for (int i = 0; i < s.size()-1; ++i){
		bool s1 = s[i] == 'a' ? 1 : 0,s2 = s[i+1] == 'a' ? 1 : 0;
		if (s1&&s2) dfs(s.substr(0,i+1) + caa + s.substr(i+1,s.size()-i-1));
		else if (s1&&!s2) dfs(s.substr(0,i+1) + cab + s.substr(i+1,s.size()-i-1));
		else if (!s1&&!s2) dfs(s.substr(0,i+1) + cbb + s.substr(i+1,s.size()-i-1));
		else if (!s1&&s2) dfs(s.substr(0,i+1) + cba + s.substr(i+1,s.size()-i-1));
	}
}
inline int all1(){
	for (int i = 2; i <= 10; ++i) if (ans[i] ^ 1) return 0;
	return 1;
}
inline int pw2(){
	for (int i = 2; i <= 3; ++i) if (ans[i] ^ 1) return 0;
	for (int i = 4,now = 2; i <= 10; ++i,now *= 2) if (ans[i] ^ now) return 0;
	return 1;
}
int fib[1005];
int main(){
//	caa = 'b';
//	cab = 'b';
//	cba = 'a';
//	cbb = 'b';
	fib[2] = 1,fib[3] = 1;
	for (int i = 4; i <= 1000; ++i) fib[i] = (fib[i-1] + fib[i-2]) %P;
	cin>>n>>caa>>cab>>cba>>cbb;
	if (n<=3)cout<<1<<'\n',exit(0);
	caa -= 'A'-'a';
	cab -= 'A'-'a';
	cba -= 'A'-'a';
	cbb -= 'A'-'a';

	dfs("ab");
//	for (int i = 2; i <= 10; ++i) cout<<i<<' '<<ans[i]<<'\n';
	if (all1()) cout<<1<<'\n',exit(0);
	if (pw2()){
		int ans=  1;
		for (int i = 1; i <= n-3; ++i) ans=ans*2%P;
		cout<<ans<<'\n';exit(0);
	}
	cout<<fib[n]<<'\n';
	return 0;
}
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
#include<array>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;
const ld pi = acosl(-1.0);

ll mod_pow(ll x, ll n, ll m = mod) {
	if (n < 0) {
		ll res = mod_pow(x, -n, m);
		return mod_pow(res, m - 2, m);
	}
	if (abs(x) >= m)x %= m;
	if (x < 0)x += m;
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % m;
		x = x * x % m; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, ll n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
modint operator/=(modint& a, modint b) { a = a / b; return a; }
const int max_n = 1 << 1;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
modint combP(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[a - b];
}

void solve() {
	ll a, b, c; cin >> a >> b >> c;
	int ida = 1; int idb = 1;
	if (a < 0 && c % 2)ida = -1;
	if (b < 0 && c % 2)idb = -1;
	a = abs(a); b = abs(b);
	if (ida != idb) {
		if (ida < 0)cout << "<";
		if (idb < 0)cout << ">";
		cout << "\n";
		return;
	}
	if (a == b) {
		cout << "=\n"; return;
	}
	if (ida >= 0) {
		if (a < b)cout << "<";
		else cout << ">";
	}
	else {
		if (a < b)cout << ">";
		else cout << "<";
	}
	cout << "\n";
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	//init_f();
	//init(); cout << ps.size() << "\n";
	//expr();
	//int t; cin >> t; rep(i, t)
	solve();
	return 0;
}

