Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official.
×

Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

The problem statement has recently been changed. View the changes.

×
A. Power Consumption Calculation

time limit per test

1 secondmemory limit per test

256 megabytesinput

standard inputoutput

standard outputTom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes *P*_{1} watt per minute. *T*_{1} minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to *P*_{2} watt per minute. Finally, after *T*_{2} minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes *P*_{3} watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into *n* time periods [*l*_{1}, *r*_{1}], [*l*_{2}, *r*_{2}], ..., [*l*_{n}, *r*_{n}]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period [*l*_{1}, *r*_{n}].

Input

The first line contains 6 integer numbers *n*, *P*_{1}, *P*_{2}, *P*_{3}, *T*_{1}, *T*_{2} (1 ≤ *n* ≤ 100, 0 ≤ *P*_{1}, *P*_{2}, *P*_{3} ≤ 100, 1 ≤ *T*_{1}, *T*_{2} ≤ 60). The following *n* lines contain description of Tom's work. Each *i*-th of these lines contains two space-separated integers *l*_{i} and *r*_{i} (0 ≤ *l*_{i} < *r*_{i} ≤ 1440, *r*_{i} < *l*_{i + 1} for *i* < *n*), which stand for the start and the end of the *i*-th period of work.

Output

Output the answer to the problem.

Examples

Input

1 3 2 1 5 10

0 10

Output

30

Input

2 8 4 2 5 10

20 30

50 100

Output

570

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Sep/21/2021 01:54:42 (h1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|