Problem:
Score : 600 points

Problem Statement

There are N points in a two-dimensional plane. The initial coordinates of the i-th point are (x_i, y_i). Now, each point starts moving at a speed of 1 per second, in a direction parallel to the x- or y- axis. You are given a character d_i that represents the specific direction in which the i-th point moves, as follows:

If d_i = R, the i-th point moves in the positive x direction;

If d_i = L, the i-th point moves in the negative x direction;

If d_i = U, the i-th point moves in the positive y direction;

If d_i = D, the i-th point moves in the negative y direction.

You can stop all the points at some moment of your choice after they start moving (including the moment they start moving).
Then, let x_{max} and x_{min} be the maximum and minimum among the x-coordinates of the N points, respectively. Similarly, let y_{max} and y_{min} be the maximum and minimum among the y-coordinates of the N points, respectively.

Find the minimum possible value of (x_{max} - x_{min}) \times (y_{max} - y_{min}) and print it.

Constraints

1 \leq N \leq 10^5

-10^8 \leq x_i,\ y_i \leq 10^8

x_i and y_i are integers.

d_i is R, L, U, or D.

Input

Input is given from Standard Input in the following format:

N
x_1 y_1 d_1
x_2 y_2 d_2
.
.
.
x_N y_N d_N

Output

Print the minimum possible value of (x_{max} - x_{min}) \times (y_{max} - y_{min}).

The output will be considered correct when its absolute or relative error from the judge's output is at most 10^{-9}.

Sample Input 1

2
0 3 D
3 0 L

Sample Output 1

0

After three seconds, the two points will meet at the origin. The value in question will be 0 at that moment.

Sample Input 2

5
-7 -10 U
7 -6 U
-8 7 D
-3 3 D
0 -6 R

Sample Output 2

97.5

The answer may not be an integer.

Sample Input 3

20
6 -10 R
-4 -9 U
9 6 D
-3 -2 R
0 7 D
4 5 D
10 -10 U
-1 -8 U
10 -6 D
8 -5 U
6 4 D
0 3 D
7 9 R
9 -4 R
3 10 D
1 9 U
1 -6 U
9 -8 R
6 7 D
7 -3 D

Sample Output 3

273

Solution in C# (Mono 4.6.2.0) (judge verdict: Runtime Error)

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using SB = System.Text.StringBuilder;
//using System.Threading.Tasks;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
using System.Numerics;
using static System.Math;
using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    readonly int dom = 998244353;
    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void solve()
    {
        int N = cin.nextint;

        var stop_x_max = long.MinValue;
        var stop_x_min = long.MaxValue;
        var stop_y_max = long.MinValue;
        var stop_y_min = long.MaxValue;


        var plus_x_max = long.MinValue;
        var plus_x_min = long.MaxValue;

        var minus_x_min = long.MaxValue;
        var minus_x_max = long.MinValue;

        var plus_y_max = long.MinValue;
        var plus_y_min = long.MaxValue;


        var minus_y_min = long.MaxValue;
        var minus_y_max = long.MinValue;

        var X = new long[N];
        var Y = new long[N];
        var D = new int[N];

        for (int i = 0; i < N; i++)
        {
            var x = cin.nextlong;
            var y = cin.nextlong;
            var d = cin.next[0];
            X[i] = x;
            Y[i] = y;
            //D[i] = d;

            if (d == 'R')
            {
                chmax(ref plus_x_max, x);
                chmin(ref plus_x_min, x);
                chmax(ref stop_y_max, y);
                chmin(ref stop_y_min, y);
                D[i] = 0;
            }
            else if (d == 'L')
            {
                chmax(ref minus_x_max, x);
                chmin(ref minus_x_min, x);
                chmax(ref stop_y_max, y);
                chmin(ref stop_y_min, y);
                D[i] = 2;
            }
            else if (d == 'U')
            {
                chmax(ref plus_y_max, y);
                chmin(ref plus_y_min, y);
                chmax(ref stop_x_max, x);
                chmin(ref stop_x_min, x);
                D[i] = 3;
            }
            else
            {
                chmax(ref minus_y_max, x);
                chmin(ref minus_y_min, x);
                chmax(ref stop_x_max, x);
                chmin(ref stop_x_min, x);
                D[i] = 1;
            }
        }

        var L = new List<long>();
        L.Add(0);

        if (stop_x_min <= minus_x_min)
        {
            L.Add(minus_x_min - stop_x_min);
        }
        if (stop_x_max <= minus_x_max)
        {
            L.Add(minus_x_max - stop_x_max);
        }
        if (plus_x_min <= stop_x_min)
        {
            L.Add(stop_x_min - plus_x_min);
        }
        if (plus_x_max <= stop_x_max)
        {
            L.Add(stop_x_max - plus_x_max);
        }

        if (stop_y_min <= minus_y_min)
        {
            L.Add(minus_y_min - stop_y_min);
        }
        if (stop_y_max <= minus_y_max)
        {
            L.Add(minus_y_max - stop_y_max);
        }
        if (plus_y_min <= stop_y_min)
        {
            L.Add(stop_y_min - plus_y_min);
        }
        if (plus_y_max <= stop_y_max)
        {
            L.Add(stop_y_max - plus_y_max);
        }


        long ans = long.MaxValue;
        foreach (var item in L)
        {
            //WriteLine(item);
            long x_min = long.MaxValue;
            long x_max = long.MinValue;
            long y_min = long.MaxValue;
            long y_max = long.MinValue;

            for (int i = 0; i < N; i++)
            {
               var xx = X[i] + D[dd[i + 1]] * item;
                var yy = Y[i] + D[dd[i]] * item;
                chmin(ref x_min, xx);
                chmax(ref x_max, xx);
                chmin(ref y_min, yy);
                chmax(ref y_max, yy);

            }
            chmin(ref ans, (x_max - x_min) * (y_max - y_min));
        }

        WriteLine(ans);

    }

}


static class Ex
{
    public static void join<T>(this IEnumerable<T> values, string sep = " ") => WriteLine(string.Join(sep, values));
    public static string concat<T>(this IEnumerable<T> values) => string.Concat(values);
    public static string reverse(this string s) { var t = s.ToCharArray(); Array.Reverse(t); return t.concat(); }

    public static int lower_bound<T>(this IList<T> arr, T val) where T : IComparable<T>
    {
        int low = 0, high = arr.Count;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (arr[mid].CompareTo(val) < 0) low = mid + 1;
            else high = mid;
        }
        return low;
    }
    public static int upper_bound<T>(this IList<T> arr, T val) where T : IComparable<T>
    {
        int low = 0, high = arr.Count;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (arr[mid].CompareTo(val) <= 0) low = mid + 1;
            else high = mid;
        }
        return low;
    }
}

class Pair<T, U> : IComparable<Pair<T, U>> where T : IComparable<T> where U : IComparable<U>
{
    public T f; public U s;
    public Pair(T f, U s) { this.f = f; this.s = s; }
    public int CompareTo(Pair<T, U> a) => f.CompareTo(a.f) != 0 ? f.CompareTo(a.f) : s.CompareTo(a.s);
    public override string ToString() => $"{f} {s}";
}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan => ReadLine().Split();
    public int[] scanint => Array.ConvertAll(scan, int.Parse);
    public long[] scanlong => Array.ConvertAll(scan, long.Parse);
    public double[] scandouble => Array.ConvertAll(scan, double.Parse);
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint => int.Parse(next);
    public long nextlong => long.Parse(next);
    public double nextdouble => double.Parse(next);
}