D. Door 1
time limit per test
4 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

Pick a door.

The door you choose will determine your fate for the next $$$N$$$ hours.

4, 3, 2, 1...

Door 1, "the ferret burrow".

You find yourself inside a vast underground labyrinth: tunnels branching in every direction, narrow passages, hidden chambers, and faint scratching sounds echoing through the walls. The air is warm, dense, and carries a faint earthy smell. In your hand, you carry a lamp.

You are not alone. This is a burrow inhabited by ferrets.

Some ferrets are harmless, timid creatures that scatter at the slightest noise. Others are not. There are also light-sensitive ferrets: if they spot you wandering through the dark tunnels, they will rush toward you unless you scare them away with your lamp. But the most dangerous of all is the giant ferret: silent, fast, and impossible to escape if you encounter it outside your hiding place.

Your lamp requires exactly two batteries to work, and both are consumed when it is used.

You carry a small bag that can hold at most $$$K$$$ batteries. Initially, you have $$$S$$$ batteries.

Every hour, you must choose exactly one action:

  • Hide. You stay still in a safe chamber. No ferret can attack you while you are hiding.
  • Search for a battery. You explore the tunnels, hoping to find a usable battery. During the $$$i$$$-th hour, you find exactly one battery with probability $$$b_i$$$.
  • Search for food. You look for something edible. During the $$$i$$$-th hour, you find food with probability $$$c_i$$$. However, not all food is safe: if you find food, you die from poisoning with probability $$$v_i$$$. If you eat and survive, your hunger is reset.

Being outside your hiding place exposes you to the ferrets.

During the $$$i$$$-th hour, a light-sensitive ferret appears with probability $$$q_i$$$. If that happens while you are searching for a battery or food, you must use your lamp to survive. If you have fewer than two batteries before that hour, the ferret captures you, and you die. If you use your lamp, exactly two batteries are consumed.

The giant ferret appears during the $$$i$$$-th hour with probability $$$p$$$. Unfortunately, you do not know the exact value of $$$p$$$, but you know that it was chosen uniformly at random from $$$[0,1]$$$ before you entered the ferret burrow, and that it remains fixed for all $$$N$$$ hours. If it appears while you are searching for a battery or food, you are captured with certainty.

At the beginning of each hour, you must choose your action before knowing whether a light-sensitive ferret or the giant ferret will appear during that hour. If you choose to hide, you will still know whether the giant ferret appeared during that hour, although it cannot attack you.

Staying in these tunnels is exhausting. You must successfully eat at least once every $$$H$$$ hours. Otherwise, you die from exhaustion.

If you manage to survive for $$$N$$$ hours, you can escape.

You chose door 1. What is the maximum probability of survival if you act optimally?

Input

The first line contains four integers $$$N$$$, $$$K$$$, $$$S$$$ and $$$H$$$ ($$$1 \leq N \leq 500$$$, $$$1 \leq K,H \leq 12$$$ and $$$0 \leq S \leq K$$$).

The $$$i$$$-th of the next $$$N$$$ lines contains four real numbers $$$b_i$$$, $$$c_i$$$, $$$v_i$$$ and $$$q_i$$$ ($$$0 \leq b_i, c_i, v_i, q_i \leq 1$$$). These numbers are given with exactly four digits after the decimal point  — the probabilities for the $$$i$$$-th day.

Output

In a single line, print a real number  — the maximum probability of survival if you act optimally.

The answer will be considered correct if its relative or absolute error doesn't exceed $$$10^{-9}$$$.

Examples
Input
2 12 12 1
0.0000 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000
Output
0.0000000000
Input
2 12 12 2
0.0000 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000
Output
0.0000000000
Input
2 12 12 3
0.0000 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000
Output
1.0000000000
Input
1 12 1 1
1.0000 1.0000 0.5000 0.5000
Output
0.1250000000
Input
5 12 3 3
0.0123 0.4567 0.8901 0.2345
0.4567 0.8901 0.2345 0.0123
0.8901 0.2345 0.0123 0.4567
0.2345 0.0123 0.4567 0.8901
0.0123 0.4567 0.8901 0.2345
Output
0.1158078250
Input
4 12 12 2
0.1234 0.0000 0.0000 0.0000
0.4321 1.0000 0.5000 0.0000
0.5678 1.0000 0.0000 1.0000
0.8764 0.0000 0.0000 0.0000
Output
0.1666666667