There is an interval

initially. For an interval

, if

, there will be two possible changes:
* Shrinking,

changes to

or

* Expanding,

changes to
%7D)
or
%7D)
So, when

, the interval will be unable to be changed. You don't want to see this, so you may need to ban some changing manners.
Specifically, we use tuple
%7D)
to describe banning. If

, you can ban the bidirectional changing between

and

with cost

while you can ban the bidirectional changing between

and

with cost

if

.
Determine the minimum total cost to guarantee that

will never happen. Print "-1" if it's impossible to make it.