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.util.*;
import java.io.*;

// public class Solution implements Runnable
class Solution implements Runnable
{
	public static void main(String[] args) throws IOException  {
		br=new BufferedReader(new InputStreamReader(System.in));
		nextIntBuffer = new String[0];
		bos = new OutputStreamWriter(new BufferedOutputStream(System.out));
		new Thread(null, new Solution(), "Main", 1<<28).start();
	}

	static BufferedReader br;
	static String nextIntBuffer[];
	static int nextIntBase;
	static OutputStreamWriter bos;
	static int nextInt() {
		return Integer.parseInt(next());
	}

	static long nextLong() {
		return Long.parseLong(next());
	}

	static String next() {
		try{
			if(nextIntBase>=nextIntBuffer.length) {
				nextIntBase =0;
				nextIntBuffer = br.readLine().split(" ");
			}
		}catch(IOException e) {}
		return nextIntBuffer[nextIntBase++];
	}


	static void print (String s)    {try{ bos.write(s);	}catch(IOException e){}}
	static void print (int s)  {try{ bos.write(String.valueOf(s));	}catch(IOException e){}}
	static void print (long s)  {try{ bos.write(String.valueOf(s));	}catch(IOException e){}}
	static void print (double s)  {try{ bos.write(String.valueOf(s));	}catch(IOException e){}}
	static void println (String s)  {try{ print(s); 	bos.write('\n');	}catch(IOException e){}}
	static void println (int s)  {try{ print(s); 	bos.write('\n');	}catch(IOException e){}}
	static void println (long s)  {try{ print(s); 	bos.write('\n');	}catch(IOException e){}}
	static void println (double s)  {try{ print(s); 	bos.write('\n');	}catch(IOException e){}}

		public static <T1 extends Comparable<T1> ,T2 extends Comparable<T2> > Pair<T1,T2> mp(T1 a,T2 b) {
		return new Pair<T1,T2>(a,b);
	}


	public void main()  {
		br=new BufferedReader(new InputStreamReader(System.in));
		nextIntBuffer = new String[0];

		int n=nextInt();
		int s=nextInt();
		ArrayList<Pair<Integer,Integer>> left=new ArrayList<Pair<Integer,Integer>>();
		ArrayList<Pair<Integer,Integer>> right=new ArrayList<Pair<Integer,Integer>>();
		for (int i=0;i<n ;i++ ) 
		{
			int x=nextInt();
			int v=nextInt();
			int d=nextInt();
			if(d==1)
				left.add(new Pair<Integer,Integer>(x,v));
			if(d==2)
				right.add(new Pair<Integer,Integer>(x,v));
		}

		double l1=0,l2=(double)1e6;
		while(Math.abs(l1-l2)>1e-8)
		{
			// l2=l1=0.01; 
		int[] a=new int[(int)1e6+1];
		int[] b=new int[(int)1e6+1];
			double t=(l1+l2)/2;
			// println(t);
			//left
			for (int i=0;i<left.size();i++ ) {
				long v=left.get(i).b;
				int d=left.get(i).a;
				if(((1.0*d)/v)<=t) {
					Arrays.fill(a,1);break;
				}
				double d1=(t*v*(v+s)-d*v)/s;
				// println(d1);

				int x=(int)((d-d1)+(d1*s)/v);
				x=Math.min(x,(int)1e6-1)+1;
				if(d>x) continue;
				// println(d+ " < "+x);
				// println("interval for left "+ d+" ::::" + Math.min(x,(int)1e6));
				// println(left.size()+"  "+right.size());
				a[x]+=-1;
				a[d]+=1;
			}
			//right
			for (int i=0;i<right.size() ;i++ ) {
				long v=right.get(i).b;
				int d=(int)1e6-right.get(i).a;
				if((1.0*d/v)<=t) {
				Arrays.fill(b,1);
					break;
				}
				double d1=(t*v*(v+s)-(long)d*v)/s;
				int x=(int)((d-d1)+(d1*s)/v);
				if(d>x) continue;
				x=(int)1e6-x;
				
				// println("interval for right "+Math.max(0,x)+"::::"+right.get(i).a);
				b[Math.max(0,x)]+=1;
				b[right.get(i).a+1]+=-1;

			}
			for (int i=1;i<a.length ;i++ ) {
				a[i]+=a[i-1];	
			}
			for (int i=1;i<b.length ;i++ ) {
				b[i]+=b[i-1];	
			}
			boolean flag=false;
			for (int i=0;i<a.length ;i++ ) {
				if(a[i]!=0 && b[i]!=0)
					flag=true;
			}	
			if(flag)
			{
				l2=t;
			}
			else
				l1=t;
		}
		
		println(l1);
	}

	// int gettimel(int v,int s,int d)
	// {
	// 	int t1=d/(s-v);
	// 	int d2=s*t1;
	// 	int t=Math.abs(d-d2)/(v+s);
	// 	return t+t1;
	// }

	// int gettimer(int v,int s,int d)
	// {
	// 	int d1=(d*s)/(s+v); //dist by s
	// 	int d2=d-d1; //dist by v
	// 	int t=d2/(s+v); // 
	// 	return t+(v/d2);
	// }

	public void run() {
		try
		{
			main();
			bos.flush();
		}catch(IOException e) {
			e.printStackTrace();
		}
	}

	static long pow(long x,long y,long mod)
	{
		if (y==0) return 1; 
		long z=pow(x,y/2,mod)%mod;
		if(y%2==0) return (z*z)%mod;
		else return (((x*z)%mod)*z)%mod;
		
	}

	static long gcd(long q,long d) {
		long x1[]=new long[1];long y1[]=new long[1];
		return  gcd(q,d,x1,y1);
	}
	static long gcd(long q,long d,long x[],long y[]) {
		if(d%q==0) {
			x[0]=1;
			y[0]=0;
			return q;
		}
		long x1[]=new long[1];long y1[]=new long[1];
		long ans = gcd(d%q,q,x1,y1);
		y[0]=x1[0];
		x[0]=y1[0]-(d/q)*x1[0];
		return ans;
	}
	static long Inv(long n,long m) {
		long x[]=new long[1];long y[]=new long[1];
		long g= gcd(n,m,x,y);
		if(g==1) {
			return (x[0]+m)%m;
		}
		return -1;
	}
}

class Pair<T1 extends Comparable<T1>, T2 extends Comparable<T2> > implements Comparable<Pair<T1,T2> > {
	  T1 a;
	  T2 b;
	  public Pair(T1 x, T2 y) {
	    a = x; b = y;
	  }
	  @Override
	  public int compareTo(Pair<T1,T2> other) {
	  	int comp1 = a.compareTo(other.a);
	  	if(comp1!=0)
	  		return comp1;
	    return b.compareTo(other.b);
	}
}