#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n;
  cin>>n;
  ll cxmax = -1e9;
  ll cxmin = 1e9;
  ll cymax = -1e9;
  ll cymin = 1e9;
  ll rmax = -1e9;
  ll rmin = 1e9;
  ll lmax = -1e9;
  ll lmin = 1e9;
  ll umax = -1e9;
  ll umin = 1e9;
  ll dmax = -1e9;
  ll dmin = 1e9;
  REP(i,n) {
    ll x,y;
    string d;
    cin>>x>>y>>d;
    switch(d[0]) {
      case 'R':
        cymax=max(cymax,y);
        cymin=min(cymin,y);
        rmax=max(rmax,x);
        rmin=min(rmin,x);
        break;
      case 'L':
        cymax=max(cymax,y);
        cymin=min(cymin,y);
        lmax=max(lmax,x);
        lmin=min(lmin,x);
        break;
      case 'U':
        cxmax=max(cxmax,x);
        cxmin=min(cxmin,x);
        umax=max(umax,y);
        umin=min(umin,y);
        break;
      case 'D':
        cxmax=max(cxmax,x);
        cxmin=min(cxmin,x);
        dmax=max(dmax,y);
        dmin=min(dmin,y);
        break;
    }
  }
  vector<vector<tuple<ll,ll>>> eqs(4);
  if (lmax != -1e9) eqs[0].emplace_back(-1,lmax);
  if (cxmax != -1e9) eqs[0].emplace_back(0,cxmax);
  if (rmax != -1e9) eqs[0].emplace_back(1,rmax);
  if (lmin != 1e9) eqs[1].emplace_back(-1,lmin);
  if (cxmin != 1e9) eqs[1].emplace_back(0,cxmin);
  if (rmin != 1e9) eqs[1].emplace_back(1,rmin);
  if (dmax != -1e9) eqs[2].emplace_back(-1,dmax);
  if (cymax != -1e9) eqs[2].emplace_back(0,cymax);
  if (umax != -1e9) eqs[2].emplace_back(1,umax);
  if (dmin != 1e9) eqs[3].emplace_back(-1,dmin);
  if (cymin != 1e9) eqs[3].emplace_back(0,cymin);
  if (umin != 1e9) eqs[3].emplace_back(1,umin);
  vector<vector<tuple<double,ll,ll>>> reqs(4);
  REP(i,4) {
    if (eqs[i].size() == 1) {
      ll a1,a0;
      tie(a1,a0) = eqs[i][0];
      reqs[i].emplace_back(0, a1, a0);
      continue;
    }
    vector<double> vt;
    REP(j,eqs[i].size())REP(k,j) {
      ll a1,a0,b1,b0;
      tie(a1,a0) = eqs[i][j];
      tie(b1,b0) = eqs[i][k];
      double t = -(a0-b0)/(double)(a1-b1);
      if (t > 0) vt.push_back(t);
    }
    sort(ALL(vt));
    vt.erase(unique(ALL(vt)),end(vt));
    {
      tuple<ll,ll> t(0, 0);
      if (i%2) {
        double mn = 1e9;
        REP(j,eqs[i].size()) {
          if (get<1>(eqs[i][j]) < mn) {
            mn = get<1>(eqs[i][j]);
            t = eqs[i][j];
          }
        }
      } else {
        double mx = -1e9;
        REP(j,eqs[i].size()) {
          if (get<1>(eqs[i][j]) > mx) {
            mx = get<1>(eqs[i][j]);
            t = eqs[i][j];
          }
        }
      }
      ll a1,a0;
      tie(a1,a0) = t;
      reqs[i].emplace_back(0,a1,a0);
    }
    REP(j,vt.size()) {
      double pt = vt[j] + 0.25;
      tuple<ll,ll> t(0, 0);
      if (i%2) {
        double mn = 1e9;
        REP(j,eqs[i].size()) {
          ll a1,a0;
          tie(a1,a0) = eqs[i][j];
          double v = a1*pt + a0;
          if (v < mn) {
            mn = v;
            t = eqs[i][j];
          }
        }
      } else {
        double mx = -1e9;
        REP(j,eqs[i].size()) {
          ll a1,a0;
          tie(a1,a0) = eqs[i][j];
          double v = a1*pt + a0;
          if (v > mx) {
            mx = v;
            t = eqs[i][j];
          }
        }
      }
      ll a1,a0;
      tie(a1,a0) = t;
      reqs[i].emplace_back(vt[j],a1,a0);
    }
  }
  vector<double> vt;
  REP(i,4) {
    REP(j,reqs[i].size()) vt.push_back(get<0>(reqs[i][j]));
  }
  sort(ALL(vt));
  vt.erase(unique(ALL(vt)), end(vt));
  vt.push_back(1e9);
  double mn = 1e18;
  REP(k,vt.size()-1) {
    if (vt[k] < 0) continue;
    double pt = vt[k] + 0.25;
    vector<tuple<ll,ll>> e(4);
    REP(i,4) {
      REP(j,reqs[i].size()) {
        double s;
        ll a1,a0;
        tie(s,a1,a0) = reqs[i][j];
        if (s < pt) {
          e[i] = make_tuple(a1, a0);
        }
      }
    }
    ll a1,a0,b1,b0,c1,c0,d1,d0;
    tie(a1,a0) = e[0];
    tie(b1,b0) = e[1];
    tie(c1,c0) = e[2];
    tie(d1,d0) = e[3];
    ll x1 = a1-b1;
    ll x0 = a0-b0;
    ll y1 = c1-d1;
    ll y0 = c0-d0;
    ll f2 = x1*y1;
    ll f1 = x1*y0 + x0*y1;
    ll f0 = x0*y0;
    double s = vt[k];
    double t = vt[k+1];
    if (f2 > 0) {
      double p = -f1 / (2.0 * f2);
      if (s < p && p < t) {
        mn = min(mn, f0 - f1*f1 / (4.0 * f2));
      } else if (p <= s) {
        mn = min(mn, f2*s*s + f1*s + f0);
      } else {
        mn = min(mn, f2*t*t + f1*t + f0);
      }
    } else if (f2 == 0) {
      if (f1 >= 0) {
        mn = min(mn, f1*s + f0);
      } else {
        mn = min(mn, f1*t + f0);
      }
    } else {
      mn = min(mn, min(f2*s*s + f1*s + f0, f2*t*t + f1*t + f0));
    }
  }
  cout << setprecision(10) << fixed << mn << endl;

  return 0;
}


Measured memory_bytes: 384