#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1001001001001001001;
const int MOD = 1000000007;

int main(){
  int n;cin>>n;
  vector<ll> r;
  vector<ll> g;
  vector<ll> b;
  for(int i=0;i<2*n;i++) {
    ll a;char c;cin>>a>>c;
    if(c=='R') r.push_back(a);
    else if(c=='G') g.push_back(a);
    else if(c=='B') b.push_back(a);
  }
  sort(r.begin(),r.end());
  sort(g.begin(),g.end());
  sort(b.begin(),b.end());
  if(r.size()%2==0 && g.size()%2==0 && b.size()%2==0) cout << 0 << endl;
  else {
    if(r.size()%2==0) swap(r,b);
    else if(g.size()%2==0) swap(g,b);
    ll mi = INF;
    ll rbmi = INF;
    ll gbmi = INF;
    int rsize = r.size();
    int gsize = g.size();
    int bsize = b.size();
    if(bsize!=0) {
    for(int i=0;i<rsize;i++) {
      int idx = lower_bound(b.begin(),b.end(),r.at(i)) - b.begin();
      if(idx!=0 && idx!=bsize) {
        ll temp = min(abs(r.at(i)-b.at(idx)),
                      abs(r.at(i)-b.at(idx-1)));
        rbmi = min(rbmi,temp);
      } else if(idx==bsize) {
        ll temp = abs(r.at(i)-b.at(idx-1));
        rbmi = min(rbmi,temp);
      } else {
        ll temp = abs(r.at(i)-b.at(idx));
        rbmi = min(rbmi,temp);
      }
    }
    for(int i=0;i<gsize;i++) {
      int idx = lower_bound(b.begin(),b.end(),g.at(i)) - b.begin();
      if(idx!=0 && idx!=bsize) {
        ll temp = min(abs(g.at(i)-b.at(idx)),
                      abs(g.at(i)-b.at(idx-1)));
        gbmi = min(gbmi,temp);
      } else if(idx==bsize) {
        ll temp = abs(g.at(i)-b.at(idx-1));
        gbmi = min(gbmi,temp);
      } else {
        ll temp = abs(g.at(i)-b.at(idx));
        gbmi = min(gbmi,temp);
      }
    }
    mi = min(mi,rbmi + gbmi);
    }
    
    for(int i=0;i<rsize;i++) {
      int idx = lower_bound(g.begin(),g.end(),r.at(i)) - g.begin();
      ll mi2;
      if(idx!=0 && idx!=gsize) mi2 = min(abs(r.at(i)-g.at(idx)),
                                            abs(r.at(i)-g.at(idx-1)));
      else if(idx==gsize) mi2 = abs(r.at(i)-g.at(idx-1));
      else mi2 = abs(r.at(i)-g.at(idx));
      mi = min(mi,mi2);
    }
    cout << mi << endl;
  }
}
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define int long long int
#define popcount(x) __builtin_popcountll(x)
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define fr first
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define ld long double
// const int INF = __LONG_LONG_MAX__;
#define rall(a) (a).rbegin(),(a).rend()
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroint-loops")

int power(int b,int e,int m)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
int power( int b, int e)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(int x)
{
    // x wiint check if x == 0 and !(x & (x - 1)) wiint check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
}

int collinear(int x1, int y1, int x2,  
               int y2, int x3, int y3) 
{ 
    // Calculation the area of  
    // triangle. We have skipped  
    // multiplication with 0.5  
    // to avoid floating point  
    // computations  
    int a = x1 * (y2 - y3) +  
            x2 * (y3 - y1) +  
            x3 * (y1 - y2); 
  
    if (a == 0) 
        return 1; 
    else
        return 0; 
}

void solve()
{
  int n;
  cin>>n;
  vector <pair<int,int> > v;
  for(int i=0;i<n;i++)
  {
    int a,b;
    cin>>a>>b;
    v.pb({a,b});
  }
  for(int i=0;i<n-2;i++)
  {
    for(int j=i+1;j<n-1;j++)
    {
      for(int k=j+1;k<n;k++)
      {
        if(collinear(v[i].fr,v[i].sc,v[j].fr,v[j].sc,v[k].fr,v[k].sc))
        {
          cout<<"Yes";
          return;
        }
      }
    }
  }
  cout<<"No";
}


signed main()
{
  fastio
  int tt=1;
  // cin>>tt;
  //  freopen("input.txt", "r" , stdin);
  // freopen("output.txt", "w", stdout);
  while(tt--)
  {
      solve();
      cout<<"\n";
  }
  return 0;
}



