The first line has three numbers, N, M, and Q,
where N is the number of rows in the grid and M is the number of columns.
1≤N,M≤1500
1≤Q≤50,000
On the next N lines is a representation of the grid,
where characters represent empty cells (.), hay (#),
Bessie's starting position (A), and the box's initial location (B).
This is followed by Q lines, each with a pair of integers (R,C).
For each pair, you should determine if it is possible to get the box to that cell at row R, column C,
starting from the initial state of the barn. The top row is row 1, and the left column is column 1.