#include<bits/stdc++.h>
#define REP(i,n) for (int i = 1; i <= n; i++)
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define lli long long int
#define INF 1000000000
#define endl '\n'
using namespace std;
typedef long long ll;

struct fhash {
	ll operator() (ll x) const { return 7; }
};


ll fun(vector<ll> a,vector<ll> b){
    int n=a.size();
    int m=b.size();
     
    ll mn=LLONG_MAX;
    for(int i=0;i<n;i++){
        int j = lower_bound(b.begin(), b.end(), a[i])- b.begin();
         
        if(j<m){
            mn=min(mn,abs(a[i]-b[j]));
        }
        if(j-1>=0){
            mn=min(mn,abs(a[i]-b[j-1]));
        }
        if(j+1<m){
            mn=min(mn,abs(a[i]-b[j+1]));
        }
    }
     
    return mn;
}

 int main(){
    int n;
    cin>>n;
    
    vector<ll> r,g,b;
    int r1=0,g1=0,b1=0;
    for(int i=0;i<2*n;i++){
        ll u;
        char v;
        cin>>u;
        cin>>v;
        if(v=='R'){
            r1++;
           r.pb(u); 
        }else if(v=='G'){
            g1++;
            g.pb(u);
        }else{
            b1++;
            b.pb(u);
        }
    }
    
    sort(r.begin(),r.end());
    sort(g.begin(),g.end());
    sort(b.begin(),b.end());
     
     ll ans=LLONG_MAX;
     
    if(r1%2==0&&g1%2==0){
        ans=0;
    }else if(r1%2==g1%2){
        if(b1>0){
            ans=fun(r,b)+fun(g,b);
        }
        ans=min(ans,fun(r,g));
    }else if(r1%2==b1%2){
       if(g1>0){
            ans=fun(r,g)+fun(b,g);
        }
        ans=min(ans,fun(r,b));
    }else{
        if(r1>0){
            ans=fun(b,r)+fun(g,r);
        }
        ans=min(ans,fun(b,g));
    }
    
    cout<<ans<<"\n";
    
        
  return 0;
}




#include <bits/stdc++.h>
using namespace std;

class UnionFind {
private:
  int N;
  vector<int> PS;

public:
  UnionFind() : N(0) {}
  UnionFind(int n) : N(n), PS(n, -1) {}
  bool unite(int a, int b) {
    int x = root(a), y = root(b);
    if (x == y) return false;
    if (-PS.at(x) < -PS.at(y)) swap(x, y);
    PS.at(x) += PS.at(y);
    PS.at(y) = x;
    return true;
  }
  bool same(int a, int b) { return root(a) == root(b); }
  int root(int a) {
    if (PS.at(a) < 0) return a;
    return PS.at(a) = root(PS.at(a));
  }
  int size(int a) { return -PS.at(root(a)); }
  vector<vector<int>> groups() {
    vector<int> B(N), S(N);
    for (int i = 0; i < N; i++) {
      B.at(i) = root(i);
      S.at(B.at(i))++;
    }
    vector<vector<int>> ret(N);
    for (int i = 0; i < N; i++) {
      ret.at(i).reserve(S.at(i));
    }
    for (int i = 0; i < N; i++) {
      ret.at(B.at(i)).push_back(i);
    }
    auto f = [&](const vector<int> &v) { return v.empty(); };
    ret.erase(remove_if(ret.begin(), ret.end(), f), ret.end());
    return ret;
  }
};

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> V(N);
  for (int i = 0; i < N; i++) cin >> V.at(i).first >> V.at(i).second;

  auto f = [&](double mid) {
    UnionFind UF(N + 2);
    for (int i = 0; i < N; i++) {
      auto [a, b] = V.at(i);
      if (100 - b < mid) UF.unite(i, N);
      if (b - -100 < mid) UF.unite(i, N + 1);
      for (int j = 0; j < i; j++) {
        auto [c, d] = V.at(j);
        if (hypot(a - c, b - d) < mid) UF.unite(i, j);
      }
    }
    return (UF.same(N, N + 1)) ? false : true;
  };
  double ok = 0, ng = 200;
  for (int cnt = 100; cnt; cnt--) {
    double mid = (ok + ng) / 2;
    (f(mid)) ? ok = mid : ng = mid;
  }
  cout << fixed << setprecision(4) << ok / 2 << "\n";
}