Goldilocks and the N Cows

No attempts yetTime limit1sMemory limit128 MB

Problem

The story of Goldilocks and the three bears is well known. Much less known is that Goldilocks eventually took up farming. On her farm she has a barn holding NN cows (1N200001 \le N \le 20000), and those cows are sensitive to temperature.

Each cow ii has a range of temperatures AiA_i through BiB_i that feels just right to it (0AiBi1090 \le A_i \le B_i \le 10^9). If Goldilocks sets the barn thermostat to a temperature T<AiT < A_i, cow ii is too cold and produces XX units of milk. If she sets it to a temperature with AiTBiA_i \le T \le B_i, the cow is comfortable and produces YY units of milk. If she sets it to a temperature T>BiT > B_i, the cow is too hot and produces ZZ units of milk. YY is always larger than XX and also larger than ZZ.

Given XX, YY, ZZ and the preferred range of every cow, compute the maximum amount of milk Goldilocks can obtain when she sets the thermostat to the best possible value. XX, YY and ZZ are integers between 00 and 10001000, and the thermostat can be set to any integer value.

Input

  • Line 1: four space-separated integers NN, XX, YY, ZZ.
  • Lines 2 through 1+N1+N: line 1+i1+i contains the two space-separated integers AiA_i and BiB_i of cow ii.

Output

  • Line 1: the maximum amount of milk Goldilocks obtains when the barn temperature is set to the best possible value.

Hint

In the first example the barn holds four cows, whose preferred ranges are 5 through 8, 3 through 4, 13 through 20, and 7 through 10. A cold cow produces 7 units of milk, a comfortable cow produces 9, and a hot cow produces 6.

Setting the thermostat to 7 or to 8 leaves cows 1 and 4 comfortable, cow 2 too hot, and cow 3 too cold. The milk adds up to 31 units.