/**
*	created: 02.11.2020 19:03:47
**/
#ifdef _LOCAL_
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// #include <boost/math/tools/minima.hpp>
// #include <boost/range/irange.hpp>
using namespace std;
using namespace std::chrono;
#define int long long
#define name(x) #x
#define dump(x) cout << name(x) << " = " << x << endl;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rrep(i,n) for (int i = (int)(n - 1); i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define For(i,x) for (auto &i : x)
#define len(x) ll(x.size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) ll(__builtin_popcountll(bit))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a * b / __gcd(a,b)
// using boost::math::tools::brent_find_minima;
// using boost::irange;
using ll = long long;
using P = pair<int,int>;
// using bint = boost::multiprecision::cpp_int;
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 0x7fffffffffffffffll;
const int MOD1 = 1000000007;
const int MOD2 = 998244353;
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T> bool chmin(T &a, T b) {if (b < a) {a = b; return 1;} return 0;}
template<typename T> T bpow(T a, int n) {T r(1); while(n) {if (n & 1) r *= a; a *= a; n >>= 1;} return r;}
template<typename T> auto comp(vector<T> a) {sort(all(a)); a.erase(unique(all(a)),a.end()); return a;}
template<typename T,typename U> ostream &operator<<(ostream &os, const pair<T,U> &p) {os << p.first << " " << p.second; return os;}
template<typename T,typename U> ostream &operator<<(ostream &os, const map<T,U> &mp) {For(p,mp) {os << "[" << p << "]\n";} return os;}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) {rep(i,len(v)) {if(i) os << " "; os << v[i];} return os;}
template<typename T> ostream &operator<<(ostream &os, const set<T> &st) {int c(0); For(x,st) {if (c) os << " "; os << x; c++;} return os;}

// UnionFind（Disjoint-Set Data Structure）
struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n,-1) {}
    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x,y);
        par[x] += par[y]; par[y] = x;
        return true;
    }
    bool issame(int x, int y) {return root(x) == root(y);}
    int size(int x) {return -par[root(x)];}
};

void solve() {
    int n; cin >> n;
    vector<P> v(n);
    rep(i,n) {
        int a, b; cin >> a >> b;
        v[i] = P(a, b);
    }
    int s = n, t = n+1;
    vector<pair<double,P>> edge;
    rep(i,n) {
        int a = v[i].first, b = v[i].second;
        double d1 = b + 100, d2 = 100 - b;
        edge.emplace_back(d1,P(s,i));
        edge.emplace_back(d2,P(t,i));
    }
    rep(i,n) rep(j,i) {
        edge.emplace_back(hypotl(v[i].first-v[j].first,v[i].second-v[j].second),P(i,j));
    }
    sort(all(edge));
    UnionFind uf(n+2);
    int ans = 100;
    For(x, edge) {
        auto p = x.second;
        uf.merge(p.first, p.second);
        if (uf.issame(s, t)) {
            cout << x.first / 2 << endl;
            return;
        }
    }
    return;
}

signed main() {
    auto start = system_clock::now();
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    auto end = system_clock::now();
#ifdef _LOCAL_
    cout << endl << fixed << setprecision(3);
    cout << double(duration_cast<microseconds>(end-start).count())/1000;
    cout << " ms" << endl;
#endif
    return 0;
}
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
//#define MOD 998244353LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL; 
const ll llMIN=-9223372036854775808LL;

void myprint1D(vi &data)
{
  REP(i,data.size())
    cout<<data[i]<<" ";
  cout<<endl;
}

//配列を[y][x]で表示
void myprint2D_T(vvi &data)
{
  REP(i,data.size())
    myprint1D(data[i]);
}

//配列を[x][y]で表示
void myprint2D(vvi &data)
{
  ll l1=data.size();
  ll l2=data[0].size();
  REP(j,l2){
    REP(i,l1)
      cout<<data[i][j]<<" ";
    cout<<endl;
  }
}

//print(a,b...)って使い方
void print1(ll a){cout<<a<<endl;}
void print2(ll a,ll b){cout<<a<<" "<<b<<endl;}
void print3(ll a,ll b,ll c){cout<<a<<" "<<b<<" "<<c<<endl;}
void print4(ll a,ll b,ll c,ll d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void print5(ll a,ll b,ll c,ll d,ll e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}
//moddivとnCkとgarner
//c剰余下でaをbで割った値
ll moddiv(ll a,ll b,ll c){
	ll x0=c,x1=b,x2,n0=0LL,n1=1LL,n2,t=a%b,m,ans;
	if (t==0LL) return a/b;
		for(int i=0;i<900;i++){
      m=x0/x1;
      x2=x0-x1*m;
      n2=(n0-m*n1)%c;
      if (x2==1LL){
        ans=(n2+c)%c;
        break;
      }
      x0=x1;x1=x2;
      n0=n1;n1=n2;
    }
	return (a+((t*ans)%c)*b-t)/b;
}
//剰余の割ざん

//aのn乗 mod c
ll expmod(ll a,ll n,ll c){
  ll ans=1LL,aa=a,beki=n;
  for(int i=0;i<64;i++){
    if (beki%2==1LL) ans=ans*aa%c;
    aa=aa*aa%c;
    beki/=2LL;
    if (beki==0LL)break;
  }
  return ans;
}

//nCk
vi mulmod(500001);//0!,1!,2!,3!,4!,,,,
void first_nCk(){
  mulmod[0]=1LL;
  for(ll i=1;i<500001;i++){
    mulmod[i]=mulmod[i-1]*i%MOD;
  }
}
ll nCk(ll nn,ll kk){
  return moddiv(mulmod[nn],mulmod[kk]*mulmod[nn-kk]%MOD,MOD);
}

ll modinv(ll a,ll b){
  return moddiv(1,a,b);
}

ll garner(__int128_t a,__int128_t b,__int128_t ar,__int128_t br){
  __int128_t tmp=(br-ar)%b*modinv(a,b)%b;
  if (tmp<0)tmp+=b;
  return ar+tmp*a;
}




ll n;
string saa,sab,sba,sbb;

ll fib(ll nn){
  nn-=3;
  ll a0=1;
  ll a1=1;
  ll ret=1;
  for(ll nnn=0;nnn<nn;nnn++){
    a0=a1;
    a1=ret;
    ret=(a1+a0)%MOD;
  }
  return ret;
}

int main(){
  ll ans=0;
  cin >> n;

  cin>>saa>>sab>>sba>>sbb;
  if (sab=="A"){
    if (saa=="A"){
      cout<<1<<endl;
      return 0;
    }else{
      if (sba=="A"){
        ans=fib(n);
        cout<<ans<<endl;
        return 0;
      }else{
        if (n<=3){cout<<1<<endl;return 0;}
        ans=expmod(2,n-3,MOD);
        cout<<ans<<endl;return 0;
      }
    }
  }else{
    if (sbb=="B"){
      cout<<1<<endl;
      return 0;
    }else{
      if (sba=="B"){
        ans=fib(n);
        cout<<ans<<endl;
        return 0;
      }else{
        if (n<=3){cout<<1<<endl;return 0;}
        ans=expmod(2,n-3,MOD);
        cout<<ans<<endl;return 0;
      }
    }

  }



  //cout<<ans<<endl;
  return 0;
}
/*

*/