Driver Code
if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = 3 NEW_LINE M = 3 NEW_LINE K = 4 NEW_LINE query = [ [ 0 , 0 ] , [ 1 , 1 ] , [ 1 , 0 ] , [ 1 , 2 ] ] NEW_LINE result = solve ( N , M , query ) NEW_LINE for i in range ( K ) : NEW_LINE INDENT print ( result [ i ] , end = " ▁ " ) NEW_LINE DEDENT DEDENT