The list of heights is a subset of the values in the given lists. The solution is given below:
Sort the given divisors list in strictly decreasing order of D values.
Iterate over the pairs from the beginning of the sorted list. For each decrease the value of by where and
After that print the pairs where in strictly increasing order of