#include                        <bits/stdc++.h>
#include                        <ext/pb_ds/assoc_container.hpp>
#define lb                      lower_bound
#define ub                      upper_bound
#define fe(x)                   (*(x.begin()))
#define le(x)                   (*(x.rbegin()))
#define pb                      push_back
#define load(node,n)            bool operator < (const node &n) const
#define fbo(x,id)               (*(x.find_by_order(id)))
#define ook(y)                  order_of_key(y)
#define all(x)                  (x).begin(),(x).end()
#define si(a)                   scanf("%d",&a)
#define sii(a,b)                scanf("%d %d",&a,&b)
#define siii(a,b,c)             scanf("%d %d %d",&a,&b,&c)
#define sl(a)                   scanf("%lld",&a)
#define sll(a,b)                scanf("%lld %lld",&a,&b)
#define slll(a,b,c)             scanf("%lld %lld %lld",&a,&b,&c)
#define rep(i,a,b)              for(ll i = a; i<=b;  i++)
#define un(x)                   x.erase(unique(all(x)), x.end())
#define TT                      long long TC;  scanf("%lld",&TC);  for(ll tc = 1; tc<=TC; tc++)
#define read                    freopen("input.txt","r",stdin)
#define write                   freopen("output.txt","w",stdout)
#define set(x)                  tree<x,null_type,less<x>,rb_tree_tag,tree_order_statistics_node_update>
#define assign(v,n,x)           v.clear(); for(int I = 0; I<n; I++)    v.pb(x);
#define SZ(x)                   (int)x.size()
#define ff                      first
#define ss                      second
#define FF                      fflush(stdout);
#define ms(AR,x)                memset(AR,x,sizeof AR);
#define case                    printf("Case %lld: ",tc);
using                           namespace __gnu_pbds;
using                           namespace std;
typedef                         long long ll;
typedef                         pair<ll,ll> pll;
typedef                         pair<int,int> pii;

#define mx 200003

ll ara[mx];

map<char,vector<ll> > ar;



main(){
//read;

int n;
si(n);

for(int i = 0; i<2*n; i++){
    ll x;
    sl(x);
    char c;
    cin>>c;
    ar[c].pb(x);
}

ll ans = 0;
vector<char> v;
char d;

for(auto i:ar){
    if( SZ(i.ss)%2 )  v.pb(i.ff),ans = 9e18;
    else d = i.ff;
}

for(char X:{'R','G','B'})
    sort(all(ar[X]));


if(SZ(v)){
    for(ll i:ar[v[0]]){
        int id = lb( all(ar[v[1]]),i ) - ar[v[1]].begin();
        id = min( id,SZ(ar[v[1]]) - 1 );
        int id2 = id - 1;
        id2 = max(0,id2);
        ll x = ar[v[1]][id],y = ar[v[1]][id2];
        ans = min( { ans, abs(i-x) , abs(i-y) } );
    }
    if(SZ(ar[d])){
        ll tmp[mx];
        set<pll> st;
        for(ll i = 0; i<SZ(ar[d]); i++){
            ll x = ar[d][i];
            int id = lb( all(ar[v[1]]), x ) - ar[v[1]].begin();
            id = min( id,SZ(ar[v[1]]) - 1 );
            int id2 = id - 1;
            id2 = max(0,id2);
            ll p = min( abs(x - ar[v[1]][id] ) , abs( x - ar[v[1]][id2]) );
            tmp[i] = p;
            st.insert(pll(p,i));
        }

        for(ll i = 0; i<SZ(ar[d]); i++){
            pll u = pll(tmp[i],i);
            st.erase(u);
            ara[i] = fe(st).ff;
            st.insert(u);
        }

        for(ll i = 0; i<SZ(ar[d]); i++){
            ll x = ar[d][i],y,z;
            int id = lb(all(ar[v[0]]),x) - ar[v[0]].begin();
            id = min( id, SZ(ar[v[0]]) - 1);
            int id2 = id - 1;
            id2 = max(0,id2);
            y = ar[v[0]][id];
            z = ar[v[0]][id2];
            ll p = min( abs(x - y), abs(x - z) );
            ans = min(ans, p + ara[i]);
        }
    }
}

cout<<ans;


return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=5e5+10;
typedef double lb;
lb dp[N][2],sum[N][2];
int bk[N],m,n,k;

int main(){
    cin>>n>>m>>k;
    for(int i=1,x;i<=k;i++){
        cin>>x;bk[x]=1;
    }
    dp[n][0]=dp[n][1]=0;
    for(int i=n-1;i>=0;i--){
        if(bk[i]){
            dp[i][0]=1;dp[i][1]=0;
        }
        else{
            dp[i][0]=(sum[i+1][0]-sum[i+m+1][0])/(1.0*m);
            dp[i][1]=(sum[i+1][1]-sum[i+m+1][1])/(1.0*m)+1.0;
        }
        sum[i][0]=sum[i+1][0]+dp[i][0];
        sum[i][1]=sum[i+1][1]+dp[i][1];

    }
    if(fabs(dp[0][0]-1.0)<=1e-6){
        puts("-1");return 0;
    }
    //lb ans=(lb)dp[0][1]/(1.0-dp[0][0]);
    //cout<<dp[0][1]<<" "<<dp[0][0]<<endl;
    printf("%.5lf",(lb)(dp[0][1]/(lb)(1.0-dp[0][0])));
}