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 Java8 (OpenJDK 1.8.0) (judge verdict: Wrong Answer)

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        FMinimumBoundingBox solver = new FMinimumBoundingBox();
        solver.solve(1, in, out);
        out.close();
    }

    static class FMinimumBoundingBox {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.readInt();

            long[] x = new long[n];
            long[] y = new long[n];
            char[] d = new char[n];
            for (int i = 0; i < n; i++) {
                x[i] = in.readLong();
                y[i] = in.readLong();
                d[i] = in.readString().charAt(0);
            }

            double yMax = Long.MIN_VALUE;
            double yMin = Long.MAX_VALUE;
            double xMax = Long.MIN_VALUE;
            double xMin = Long.MAX_VALUE;
            double dMax = Long.MIN_VALUE;
            double uMin = Long.MAX_VALUE;
            double rMax = Long.MIN_VALUE;
            double lMin = Long.MAX_VALUE;
            double uMax = Long.MIN_VALUE;
            double dMin = Long.MAX_VALUE;
            double lMax = Long.MIN_VALUE;
            double rMin = Long.MAX_VALUE;
            for (int i = 0; i < n; i++) {
                if (d[i] == 'R' || d[i] == 'L') {
                    yMax = Math.max(yMax, y[i]);
                    yMin = Math.min(yMin, y[i]);
                } else {
                    xMax = Math.max(xMax, x[i]);
                    xMin = Math.min(xMin, x[i]);
                }
                if (d[i] == 'D') {
                    dMax = Math.max(dMax, y[i]);
                    dMin = Math.min(dMin, y[i]);
                } else if (d[i] == 'U') {
                    uMin = Math.min(uMin, y[i]);
                    uMax = Math.max(uMax, y[i]);
                } else if (d[i] == 'R') {
                    rMax = Math.max(rMax, x[i]);
                    rMin = Math.min(rMin, x[i]);
                } else {
                    lMin = Math.min(lMin, x[i]);
                    lMax = Math.max(lMax, x[i]);
                }
            }

            List<Double> cand = new ArrayList<>();
            cand.add(.0);
            cand.add(Math.abs(dMin - yMin));
            cand.add(Math.abs(yMax - uMax));
            cand.add(Math.abs(xMax - rMax));
            cand.add(Math.abs(lMin - xMin));
            cand.add(Math.abs(dMin - yMax));
            cand.add(Math.abs(yMax - uMin));
            cand.add(Math.abs(xMax - rMin));
            cand.add(Math.abs(lMin - xMax));
            cand.add(Math.abs(dMax - yMin));
            cand.add(Math.abs(yMin - uMax));
            cand.add(Math.abs(xMin - rMax));
            cand.add(Math.abs(lMax - xMin));
            cand.add(Math.abs(dMax - yMax));
            cand.add(Math.abs(yMin - uMin));
            cand.add(Math.abs(xMin - rMin));
            cand.add(Math.abs(lMax - xMax));
            cand.add(Math.abs(dMax - uMin) / 2);
            cand.add(Math.abs(dMax - uMax) / 2);
            cand.add(Math.abs(dMin - uMin) / 2);
            cand.add(Math.abs(dMin - uMax) / 2);
            cand.add(Math.abs(rMax - lMin) / 2);
            cand.add(Math.abs(rMax - lMax) / 2);
            cand.add(Math.abs(rMin - lMin) / 2);
            cand.add(Math.abs(rMin - lMax) / 2);

            double ans = Long.MAX_VALUE;
            for (int i = 0; i < cand.size(); i++) {
                double t = cand.get(i);
                for (int k = -20; k <= 20; k++) {
                    double s = t + 0.5 * k;
                    if (s < 0) continue;
                    double xxMax = Long.MIN_VALUE;
                    double xxMin = Long.MAX_VALUE;
                    double yyMax = Long.MIN_VALUE;
                    double yyMin = Long.MAX_VALUE;
                    for (int j = 0; j < n; j++) {
                        double xx = x[j];
                        double yy = y[j];
                        if (d[j] == 'U') {
                            yy += s;
                        } else if (d[j] == 'D') {
                            yy -= s;
                        } else if (d[j] == 'L') {
                            xx -= s;
                        } else {
                            xx += s;
                        }
                        xxMax = Math.max(xxMax, xx);
                        xxMin = Math.min(xxMin, xx);
                        yyMax = Math.max(yyMax, yy);
                        yyMin = Math.min(yyMin, yy);
                    }
                    ans = Math.min(ans, (xxMax - xxMin) * (yyMax - yyMin));
                }
            }

            out.printLine(String.format("%.10f", ans));
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }
}