In honor of Taekhee's graduation

Deer bounce on a line segment [0,T], each with strength; a statue at x falls when the net force of deer that have reached it exceeds W. Maximize the fall time over x.

Hard9MathSimulationPrefix sumSortingNo attempts yetTime limit3sMemory limit128 MB

Problem

After a long undergraduate career, Taekhee left the campus. Dohyun decided to put up a statue in his honor and picked the ground for it. The ground forms a number line, so the statue goes on a single point of that line, and the point does not have to be an integer coordinate.

While the statue was being finished, NN deer came down from a nearby hill. The deer run along the same number line at a constant speed and never look back. A deer that reaches the left end turns right, a deer that reaches the right end turns left, and no deer leaves the ground. Dohyun decided to put up the statue anyway. He wants it to stand as long as possible before it falls.

Dohyun found out the following.

  • A deer and the statue are points with no size.
  • Each deer has a starting point and a facing direction (left or right), and it runs in that direction at distance 1 per second. When it reaches one end of the number line, it turns around and keeps running. When two deer meet, they pass through each other and nothing happens.
  • Deer ii has strength SiS_i. A deer that reaches the statue stops there and pushes the statue forever. It pushes in the direction it was facing at the moment it arrived.
  • A push from the left and a push from the right cancel each other. For example, if one deer pushes with strength 3 from the left and another pushes with strength 2 from the right, the statue receives a force of 1 to the right.
  • If the statue stands on the starting point of some deer, that deer does not run at all and pushes the statue from the start, in the direction it faces.
  • The statue has durability WW. The moment the force on the statue exceeds WW in either direction, the statue falls.
  • If two deer reach the statue at the same moment, their two forces are added at once, with no order between them.

The moment the statue falls depends on where it stands. Find how long the statue lasts when the position is chosen as well as possible.

Input

The first line contains three integers NN, TT, WW: the number of deer, the largest coordinate of the number line, and the durability of the statue. (1N70001 \le N \le 7000, 1T10181 \le T \le 10^{18}, 0W1090 \le W \le 10^9)

The smallest coordinate of the number line is always 00.

The ii-th of the next NN lines contains three integers PiP_i, DiD_i, SiS_i: the starting position, the initial facing direction, and the strength of deer ii. Deer ii faces left if Di=0D_i = 0 and right if Di=1D_i = 1. (0PiT0 \le P_i \le T, Di=0D_i = 0 or Di=1D_i = 1, 0Si1090 \le S_i \le 10^9)

Every deer runs at the same speed of distance 1 per second.

Output

Fix a position xx for the statue and the moment the statue falls is fixed as well. Call that moment f(x)f(x). It is the first moment the force on the statue exceeds WW, and f(x)=f(x) = \infty when no such moment exists.

If f(x)=f(x) = \infty for at least one position xx, print inf on the first line.

Otherwise print on the first line the supremum, that is the least upper bound, of f(x)f(x) over all real positions xx with 0xT0 \le x \le T. Moving the statue a little can bring f(x)f(x) arbitrarily close to a value that no position reaches exactly. That value is still the answer.

The answer is always a multiple of 0.50.5, so print it with exactly one digit after the decimal point. Print 9.5 for an answer of nine and a half, and 10.0 for an answer of ten.

Hint

In the first example, put the statue at 6.56.5. At time 2.52.5 deer 3 and deer 4 arrive together and leave a force of 4 from the right to the left. At time 5.55.5 deer 2 arrives and the force drops to 0. At time 9.59.5 deer 1 arrives, the force becomes 20, and the statue falls. No position lasts longer.

In the second example, put the statue at 1010. At time 33 deer 1 and deer 2 arrive together and leave a force of 4 from the right to the left. At time 77 deer 3 arrives from the left and deer 4 arrives from the right, so the force becomes 21(4+7)=1021 - (4 + 7) = 10 from the left to the right. The durability is 10, so the statue does not fall, and no deer is left to arrive.

In the third example every deer has strength 3 and the durability is 2, so the statue falls the moment any single deer reaches it. For a position xx with 1<x<31 < x < 3, the first deer to arrive comes at time min(x+1,3x)\min(x + 1, 3 - x), and this value approaches 2 as xx approaches 1. At exactly x=1x = 1, deer 2 stands on the statue and pushes it right away, so the statue falls at time 0. No position lasts a full 2 seconds, and the answer is 2.0.