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.math.*;
import java.security.KeyStore.Entry;
import java.util.*;

public class TestClass {
	private static InputStream is;
	private static PrintWriter out;

	static ArrayList<Pair> b[];
	static int n;
	static long s;

	public static class Pair {
		long x, y;

		Pair(int a, int b) {
			x = a;
			y = b;
		}
	}

	public static boolean check(double t) {
		int bn[][] = new int[2][(int) 1e6 + 2];
		for (Pair x : b[0]) {
			double tm = x.x / (double) x.y;
			if (tm <= t) {
				bn[0][1]++;
				bn[0][(int) 1e6 + 1]--;
				continue;
			}
			tm = x.x / (double) (x.y + s);
			if (tm > t)
				continue;
			double nm = (((s * s - x.y * x.y) * t + x.x * x.y)) / s;
			nm = Math.min(nm, 1e6);
			if (nm >= x.x) {
				bn[0][(int) x.x]++;
				bn[0][(int) nm + 1]--;
			}
		}
		for (Pair x : b[1]) {
			double tm = (1e6 - x.x) / (double) x.y;
			if (tm <= t) {
				bn[1][1]++;
				bn[1][(int) 1e6 + 1]--;
				continue;
			}
			tm = (1e6 - x.x) / (double) (x.y + s);
			if (tm > t)
				continue;
			double nm = 1000000 - (((s * s - x.y * x.y) * t + (1000000 - x.x) * x.y)) / s;
			nm = Math.max(0, nm);
			nm = Math.ceil(nm);
			if (nm <= x.x) {
				bn[1][(int) x.x + 1]--;
				bn[1][(int) nm]++;
			}
		}
		for (int i = 1; i <= 1000000; i++) {
			bn[0][i] += bn[0][i - 1];
			bn[1][i] += bn[1][i - 1];
			if (bn[0][i] > 0 && bn[1][i] > 0)
				return true;
		}
		return false;
	}

	public static void solve() {
		n = ni();
		s = ni();
		b = new ArrayList[2];
		for (int i = 0; i < 2; i++)
			b[i] = new ArrayList<Pair>();
		while (n-- > 0) {
			int x = ni();
			int v = ni(), t = ni() - 1;
			b[t].add(new Pair(x, v));
		}
		double l = 0, r = 1e6 + 2;
		int tmp = 70;
		while (tmp-- > 0) {
			double mid = (l + r) / 2;
			if (check(mid))
				r = mid;
			else
				l = mid;
		}
		out.println(r);
	}

	public static void run() throws Exception {
		is = System.in;
		out = new PrintWriter(System.out);
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		out.close();
		tr(System.currentTimeMillis() - s + "ms");
	}

	public static void main(String[] args) throws Exception {
		new Thread(null, new Runnable() {
			public void run() {
				try {
					TestClass.run();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}, "1", 1 << 26).start();
	}

	// To Get Input
	// Some Buffer Methods
	private static byte[] inbuf = new byte[1024];
	public static int lenbuf = 0;
	public static int ptrbuf = 0;

	private static int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private static boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private static int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private static double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private static String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
									// ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private static int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static boolean oj = System.getProperty("ONLINE_JUDGE") != null;

	private static void tr(Object... o) {
		if (!oj)
			System.out.println(Arrays.deepToString(o));
	}
}