Problem: n people are standing on a coordinate axis in points with positive integer coordinates strictly less than 106. For each person we know in which direction (left or right) he is facing, and his maximum speed.

You can put a bomb in some point with non-negative integer coordinate, and blow it up. At this moment all people will start running with their maximum speed in the direction they are facing. Also, two strange rays will start propagating from the bomb with speed s: one to the right, and one to the left. Of course, the speed s is strictly greater than people's maximum speed.

The rays are strange because if at any moment the position and the direction of movement of some ray and some person coincide, then the speed of the person immediately increases by the speed of the ray.

You need to place the bomb is such a point that the minimum time moment in which there is a person that has run through point 0, and there is a person that has run through point 106, is as small as possible. In other words, find the minimum time moment t such that there is a point you can place the bomb to so that at time moment t some person has run through 0, and some person has run through point 106.

Input

The first line contains two integers n and s (2 ≤ n ≤ 105, 2 ≤ s ≤ 106) — the number of people and the rays' speed.

The next n lines contain the description of people. The i-th of these lines contains three integers xi, vi and ti (0 < xi < 106, 1 ≤ vi < s, 1 ≤ ti ≤ 2) — the coordinate of the i-th person on the line, his maximum speed and the direction he will run to (1 is to the left, i.e. in the direction of coordinate decrease, 2 is to the right, i.e. in the direction of coordinate increase), respectively.

It is guaranteed that the points 0 and 106 will be reached independently of the bomb's position.

Output

Print the minimum time needed for both points 0 and 106 to be reached.

Your answer is considered correct if its absolute or relative error doesn't exceed 10 - 6. Namely, if your answer is a, and the jury's answer is b, then your answer is accepted, if <image>.

Examples

Input

2 999
400000 1 2
500000 1 1


Output

500000.000000000000000000000000000000


Input

2 1000
400000 500 1
600000 500 2


Output

400.000000000000000000000000000000

Note

In the first example, it is optimal to place the bomb at a point with a coordinate of 400000. Then at time 0, the speed of the first person becomes 1000 and he reaches the point 106 at the time 600. The bomb will not affect on the second person, and he will reach the 0 point at the time 500000.

In the second example, it is optimal to place the bomb at the point 500000. The rays will catch up with both people at the time 200. At this time moment, the first is at the point with a coordinate of 300000, and the second is at the point with a coordinate of 700000. Their speed will become 1500 and at the time 400 they will simultaneously run through points 0 and 106.

Solution (in JAVA):

Solution:
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class C {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;
    static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

    /*
    The first line contains two integers n and s (2 ≤ n ≤ 105, 2 ≤ s ≤ 10^^6) — the number of people and the rays' speed.

    The next n lines contain the description of people.
    The i-th of these lines contains three integers xi, vi and ti (0 < xi < 106, 1 ≤ vi < s, 1 ≤ ti ≤ 2) —
    the coordinate of the i-th person on the line, his maximum speed and the direction
    he will run to (1 is to the left, i.e. in the direction of coordinate decrease, 2 is to the right,
     i.e. in the direction of coordinate increase), respectively.

    It is guaranteed that the points 0 and 106 will be reached independently of the bomb's position.
     */
    public static void main(String[] args) throws IOException {
        int n = in(), s = in(), nl = 0, nr = 0, start = 0, end = 1_000_000;
        Gajo[] l = new Gajo[n], r = new Gajo[n];
        for (int i = 0; i < n; i++) {
            Gajo g = new Gajo(in(), in());
            if (in() == 1)
                l[nl++] = g;
            else
                r[nr++] = g;
        }
        Arrays.sort(l, 0, nl);
        Arrays.sort(r, 0, nr);
        double tl = Double.POSITIVE_INFINITY, tr = Double.POSITIVE_INFINITY, ans = Double.POSITIVE_INFINITY;
        for (int i = 0; i < nl; i++)
            tl = Math.min(tl, l[i].x / l[i].v);
        for (int i = 0; i < nr; i++)
            tr = Math.min(tr, (end - r[i].x) / r[i].v);
        Gajo b = null, bl[] = new Gajo[end + 1], br[] = new Gajo[end + 1];
        for (int i = 0, x = start; x <= end; x++) {
            while (i < nl && l[i].x <= x) {
                Gajo g = l[i++];
                if (b == null || t(x - g.x, g.x, s, g.v) < t(x - b.x, b.x, s, b.v))
                    b = g;
            }
            bl[x] = b;
        }
        b = null;
        for (int i = nr - 1, x = end; x >= start; x--) {
            while (i >= 0 && r[i].x >= x) {
                Gajo g = r[i--];
                if (b == null || t(g.x - x, end - g.x, s, g.v) < t(b.x - x, end - b.x, s, b.v))
                    b = g;
            }
            br[x] = b;
        }
        for (int x = start; x <= end; x++) {
            double tlx = Math.min(tl, bl[x] == null ? Double.POSITIVE_INFINITY : t(x - bl[x].x, bl[x].x, s, bl[x].v)), trx = Math.min(tr, br[x] == null ? Double.POSITIVE_INFINITY : t(br[x].x - x, end - br[x].x, s, br[x].v));
            ans = Math.min(ans, Math.max(tlx, trx));
        }
        out.printf("%.31f\n", ans);
        out.flush();
    }

    static double t(int d, int D, double s, double v) {
        return d / (s * 1.0 - v) + Math.max(0, (D - (d / (s * 1.0 - v))*v) / (s * 1.0 + v));
    }

    public static int in() throws IOException {
        return Integer.parseInt(next());
    }

    public static long inl() throws IOException {
        return Long.parseLong(next());
    }

    public static double ind() throws IOException {
        return Double.parseDouble(next());
    }

    public static String next() throws IOException {
        if (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public static boolean nextPerm(int[] a) {
        int j = a.length - 1, k = j, r = j;
        for (; j > 0; j--)
            if (a[j - 1] < a[j]) break;
        if (j == 0) return false;
        for (; k > j; k--)
            if (a[j - 1] < a[k]) break;
        swap(a, j - 1, k);
        while (j < r) swap(a, j++, r--);
        return true;
    }

    public static void swap(int[] a, int i, int j) {
        int t = a[i];
        a[i] = a[j];
        a[j] = t;
    }

    public static void swap(char[] a, int i, int j) {
        char t = a[i];
        a[i] = a[j];
        a[j] = t;
    }

    public static void swap(long[] a, int i, int j) {
        long t = a[i];
        a[i] = a[j];
        a[j] = t;
    }

    static class Gajo implements Comparable<Gajo> {
        int x;
        double v;

        public Gajo(int x, int v) {
            this.x = x;
            this.v = v * 1.0;
        }

        @Override
        public int compareTo(Gajo o) {
            return Integer.compare(this.x, o.x);
        }
    }
}