In an undirected graph, a matching is a subset of the edges in which no two edges share a vertex. A maximum matching is a matching of the largest possible size.
Decide whether a graph G with all of the following properties exists. If it does, find the largest number of edges such a G can have.
G is a simple undirected graph.
G is bipartite, and its two parts have sizes n1 and n2.
The size of a maximum matching of G is ans.
Every vertex of G has degree at least d.
Input
The first line contains n1, n2, ans, and d, separated by spaces. (1≤n1,n2≤109, 1≤ans,d≤min(n1,n2))
Output
If no graph satisfies the conditions, print -1. Otherwise print the largest number of edges such a graph can have.