CF609D Gadgets for dollars and pounds
Description
Nura wants to buy $ k $ gadgets. She has only $ s $ burles for that. She can buy each gadget for dollars or for pounds. So each gadget is selling only for some type of currency. The type of currency and the cost in that currency are not changing.
Nura can buy gadgets for $ n $ days. For each day you know the exchange rates of dollar and pound, so you know the cost of conversion burles to dollars or to pounds.
Each day (from $ 1 $ to $ n $ ) Nura can buy some gadgets by current exchange rate. Each day she can buy any gadgets she wants, but each gadget can be bought no more than once during $ n $ days.
Help Nura to find the minimum day index when she will have $ k $ gadgets. Nura always pays with burles, which are converted according to the exchange rate of the purchase day. Nura can't buy dollars or pounds, she always stores only burles. Gadgets are numbered with integers from $ 1 $ to $ m $ in order of their appearing in input.
Input Format
First line contains four integers $ n,m,k,s $ ( $ 1
Output Format
If Nura can't buy $ k $ gadgets print the only line with the number -1.
Otherwise the first line should contain integer $ d $ — the minimum day index, when Nura will have $ k $ gadgets. On each of the next $ k $ lines print two integers $ q_{i},d_{i} $ — the number of gadget and the day gadget should be bought. All values $ q_{i} $ should be different, but the values $ d_{i} $ can coincide (so Nura can buy several gadgets at one day). The days are numbered from $ 1 $ to $ n $ .
In case there are multiple possible solutions, print any of them.