406090: GYM102263 L Burgers

Memory Limit:256 MB Time Limit:0 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

L. Burgerstime limit per test0.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Hiasat loves burgers, that's why he dreams about them while sleeping. One day he dreamed about an infinite grid of burgers, it can be described as an infinite grid with each cell having height of $$$n$$$ and width of $$$m$$$, inside each cell there's another grid of $$$n$$$ rows and $$$m$$$ columns with each cell having a height and width of 1.

In each cell of the $$$n \times m$$$ grid there was a burger, burgers in the first row had deliciousness equal to $$$1,2,3,...,m$$$ from left to right, in the second row the deliciousness of the burgers were equal to $$$m+1,m+2,m+3,...,2m$$$, and so on until the last row where the deliciousness of the burgers were equal to $$$(n-1)m+1,(n-1)m+2,(n-1)m+3,...,nm$$$.

Hiasat is currently standing at some cell in the infinite grid, he will repeatedly do the following: If Hiasat ate before a burger that has deliciousness equal to the deliciousness of the burger in the cell he's currently standing at then he wakes up from the dream, otherwise he eats that burger and jump $$$r$$$ rows down and $$$c$$$ columns to the right.

When Hiasat wakes up from the dream his happiness will be equal to the sum of deliciousness of all the burgers he ate in his dream, if he chooses his starting cell optimally, what is the maximum possible happiness Hiasat can wake up with(it's guaranteed that Hiasat will wake up eventually regardless of his starting cell)? Print it module $$$10^9+7$$$.

Input

A single line containing four space separated integers $$$n,m,r,c$$$($$$1\le r \le n \le 2\cdot 10^9, 1 \le c \le m \le 2\cdot 10^9$$$).

Output

Print a single integer the maximum happiness module $$$10^9+7$$$.

ExamplesInput
3 3 1 1
Output
15
Input
1 4 1 2
Output
6
Input
2000000000 1 1 1
Output
91
Note

In the first example the grid looks like the grid below, Hiasat starts at the marked cell, he eats burgers with deliciousness $$$3+4+8=15$$$.

Source/Category

加入题单

上一题 下一题 算法标签: