CF846D Monitor
Description
Recently Luba bought a monitor. Monitor is a rectangular matrix of size $ n×m $ . But then she started to notice that some pixels cease to work properly. Luba thinks that the monitor will become broken the first moment when it contains a square $ k×k $ consisting entirely of broken pixels. She knows that $ q $ pixels are already broken, and for each of them she knows the moment when it stopped working. Help Luba to determine when the monitor became broken (or tell that it's still not broken even after all $ q $ pixels stopped working).
Input Format
The first line contains four integer numbers $ n,m,k,q (1
Output Format
Print one number — the minimum moment the monitor became broken, or "-1" if it's still not broken after these $ q $ pixels stopped working.