The General Answer
First of all, we need to consider odd dimension grids and even dimension grids separately. Because their solution is close but separate.
Let's start with odd dimension one: 5x5
This is
The first numbers you need to ask for, because you would know the biggest and the smallest value in the grid. Even cells are easier in my option.
Then
you may even be able to eliminate some cells which would not be having the number you are looking for. But if you are unlucky, you may not if our number is in between all those values. For example, if $A=100$, $B=1$, $C=12$ and $D=50$, and the number you are looking for $27$, you will not able to eliminate any cell for this moment.
Let's guess
other corner values in the inner square
shown below:
This is better guess because you will able to eliminate some cells for sure now because
If our number is in between E-F you will able to eliminate first and last cells on the second column, if our number is greater/smaller than F and smaller/greater than E, we can eliminate two cells. So whatever our number is, we can eliminate two cells from the grid. For example let's say our number is $27$, $E$ is 20 and $F$ is $10$, then you can eliminate two cells etc. Likewise, we can eliminate two more cells from the second row which is not common with the column, (I will call it E-H column) Likewise on the H-G column and F-G row, we can eliminate another 4 cells whatever number we have!
So ,
So for example, one of the worst case is
Note that the red cells are the cells where our number cannot be there.
So only asking 4 more cells shown below, will eliminate another 4 cells with
the same logic above, asking for I,K,L,J will guarantee that 2 white cells left:
So
in total for 5x5, 15 cell asking guarantee to find or not your number exists. This is optimal solution for 5x5! Even if you asked for every white cells left, it would be sufficient for $4m$,
Here is why:
In general You need to ask diagonal values first, then eliminate all cells when possible, then ask for cells not to next to each other in a row or column, and eliminate accordingly. When the dimension increases, elimination number of cell you can eliminate is getting bigger, for example for 5x5, you can eliminate $8$ cells in this process, but for 7x7, you can eliminate $8+16$ cells in total.
In general, you can eliminate
$4\left (\frac{m-1}{2}-1 \right )\left (\frac{m-1}{2}\right )=m^2-4m+3$
so you asked for
$2(m-1)$ cells,
and
eliminated $m^2-4m+3$ out of $m^2$ cells
and white cell count becomes
$m^2-(m^2-4m+3)-(2m-2)=2m-1$
so we asked for
$2m-2$ and $2m-1$ cells left. If we ask all cells one by one, $4m-3$ cells would be asked which is smaller than $4m$.
As shown below (11x11):
And for the rest of while cells,
$2(m-1)$ diagonal cell asking + even you dont have to, asking the rest of while cells which is $2m-1$ is sufficient to have smaller than $4m$. For your information, asking all white cells left is not optimal, but as I said it is sufficient to have less than $4m$.