Given a 2D grid of non-negative integers grid with m rows and n columns, and a list of query cells queries, return the minimum path sum from the top-left cell (0, 0) to each queried cell. A path may move only right or down. The goal is to optimize performance when many queries are asked on the same grid.
Example 1:
Input: grid = [[1,3,1],[1,5,1],[4,2,1]], queries = [[2,2],[1,2]]
Output: [7, 6]
Explanation: The minimum path sums to (2,2) and (1,2) are 7 and 6.
Example 2:
Input: grid = [[5,1],[2,1]], queries = [[0,1],[1,1],[1,0]]
Output: [6, 7, 7]
Explanation: Precomputing all reachable minimum sums lets each query be answered in constant time.
1 <= m, n <= 5000 <= grid[r][c] <= 10^41 <= queries.length <= 10^50 <= queries[i][0] < m0 <= queries[i][1] < n