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:
//package round425;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;

public class C2 {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	
	void solve()
	{
		int n = ni(), s = ni();
		int[][] ls = new int[n][];
		int[][] rs = new int[n][];
		int lp = 0, rp = 0;
		for(int i = 0;i < n;i++){
			int[] u = na(3);
			if(u[2] == 1){
				ls[lp++] = u;
			}else{
				u[0] = 1000000-u[0];
				rs[rp++] = u;
			}
		}
		ls = Arrays.copyOf(ls, lp);
		rs = Arrays.copyOf(rs, rp);
		double[] tls = go(ls, s);
		double[] trs = go(rs, s);
		double ret = Double.POSITIVE_INFINITY;
		for(int i = 0;i <= 1000000;i++){
			ret = Math.min(ret, Math.max(tls[i], trs[1000000-i]));
		}
		out.printf("%.14f\n", ret);
	}
	
	double[] go(int[][] ds, int s)
	{
		Arrays.sort(ds, new Comparator<int[]>() {
			public int compare(int[] a, int[] b) {
				return a[0] - b[0];
			}
		});
		int n = ds.length;
		double[][] slopes = new double[n][];
		for(int i = 0;i < n;i++){
			double slope = (double)s/(s-ds[i][1])/(s+ds[i][1]);
			double inc = -(double)ds[i][1]*ds[i][0]/(s-ds[i][1])/(s+ds[i][1]);
			slopes[i] = new double[]{slope, inc};
		}
		EnvelopeLinear[] els = new EnvelopeLinear[17];
		int p = 0;
		double[][] temp = new double[n][];
		double[] ret = new double[1000001];
		double basemin = Double.POSITIVE_INFINITY;
		for(int[] d : ds){
			basemin = Math.min((double)d[0]/d[1], basemin);
		}
		for(int h = 0;h <= 1000000;h++){
			while(p < n && ds[p][0] == h){
				// (hs-vx)/(s-v)(s+v)
				p++;
				int u = Integer.numberOfTrailingZeros(p);
				for(int i = 0;i < u;i++){
					merge(slopes, p-(1<<i+1), p-(1<<i), p, temp);
				}
				els[u] = new EnvelopeLinear((1<<u));
				for(int i = p-(1<<u);i < p;i++){
					els[u].add(slopes[i][0], slopes[i][1]);
				}
			}
			double min = basemin;
			for(int i = 0;i < 17;i++){
				if(p<<~i<0){
					min = Math.min(min, els[i].min(h));
				}
			}
			ret[h] = min;
		}
		return ret;
	}
	
	public static double[][] merge(double[][] a, int l, int m, int r, double[][] temp)
	{
		int j = m, p = 0;
		for(int i = l;i < m;i++){
			while(j < r && !(a[i][0] > a[j][0]))temp[p++] = a[j++];
			temp[p++] = a[i];
		}
		while(j < r)temp[p++] = a[j++];
		assert p == r-l;
		System.arraycopy(temp, 0, a, l, r-l);
		return a;
	}

	
	public static class EnvelopeLinear {
		public static final double INF = Double.NEGATIVE_INFINITY;
		
		public double[] xs;
		public double[] intercepts, slopes;
		public int p;
		
		public EnvelopeLinear(int n)
		{
			xs = new double[n];
			intercepts = new double[n];
			slopes = new double[n];
			p = 0;
		}
		
		public void clear()
		{
			p = 0;
		}
		
		public void add(double slope, double intercept)
		{
			assert p == 0 || slopes[p-1] >= slope;
			while(p > 0){
				int i = p-1;
				if(p > 1 && intercept+xs[i]*slope <= intercepts[i]+xs[i]*slopes[i]){ // x=xs[i]
					p--;
					continue;
				}
				if(slope == slopes[i]){
					if(intercept >= intercepts[i]){
						return;
					}else{
						p--;
						continue;
					}
				}
				// y=sx+i vs y=Sx+I
				// sx+i=Sx+I
				// x=(i-I)/(S-s)
				double num = intercept-intercepts[i];
				double den = slopes[i]-slope;
				xs[p] = num/den;
				intercepts[p] = intercept;
				slopes[p] = slope;
				p++;
				return;
			}
			
			xs[p] = INF;
			intercepts[p] = intercept;
			slopes[p] = slope;
			p++;
		}
		
		public int argmin(double x)
		{
			if(p <= 0)return -1;
			int ind = Arrays.binarySearch(xs, 0, p, x);
			if(ind < 0)ind = -ind-2;
			return ind;
		}
		
		public double min(double x)
		{
			if(p <= 0)return Double.NEGATIVE_INFINITY;
			int ind = Arrays.binarySearch(xs, 0, p, x);
			if(ind < 0)ind = -ind-2;
			return slopes[ind]*x + intercepts[ind];
		}
	}
	
	double[] calc(int h, int[][] ps, int s)
	{
		double R = 1000000;
		double tor = Double.POSITIVE_INFINITY;
		double tol = Double.POSITIVE_INFINITY;
		for(int[] p : ps){
			if(p[2] == 2){
				if(h <= p[0]){
					double col = (double)(p[0]-h)/(s-p[1]);
					double goal = (R-p[0])/p[1];
					double time = goal < col ? goal : col + (R-p[0]-col*p[1])/(p[1]+s);
					tor = Math.min(tor, time);
				}else{
					double time = (R-p[0])/p[1];
					tor = Math.min(tor, time);
				}
			}else{
				if(h >= p[0]){
					double col = (double)(h-p[0])/(s-p[1]);
					double goal = (double)(p[0])/p[1];
					double time = goal < col ? goal : col + (p[0]-col*p[1])/(p[1]+s);
					tol = Math.min(tol, time);
				}else{
					double time = (double)p[0]/p[1];
					tol = Math.min(tol, time);
				}
			}
		}
		return new double[]{tol, tor};
	}
	
	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);
		
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}
	
	public static void main(String[] args) throws Exception { new C2().run(); }
	
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;
	
	private 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 boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
	
	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }
	
	private 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 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 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 boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}