```typescript
export function regionTotals(grid: number[][], queries: number[][]): number[] {
  if (!Array.isArray(grid) || grid.length === 0) {
    throw new Error("grid must be a non-empty list of rows");
  }
  const width = Array.isArray(grid[0]) ? grid[0].length : 0;
  if (width === 0) {
    throw new Error("rows must be non-empty lists");
  }

  for (const row of grid) {
    if (!Array.isArray(row) || row.length !== width) {
      throw new Error("rows must all share one length");
    }
    for (const cell of row) {
      if (!Number.isInteger(cell)) {
        throw new Error("cells must be integers");
      }
    }
  }

  const prefixSums = grid.map(row => [...row, 0]);

  for (let col = 0; col < width - 1; col++) {
    for (let row = 0; row < grid.length; row++) {
      prefixSums[row][col + 1] += prefixSums[row][col];
    }
  }

  const queryResults = queries.map(([top, left, bottom, right]) => {
    if (!Array.isArray(query) || query.length !== 4) {
      throw new Error("query must be a list of exactly four integers");
    }
    if (
      !Number.isInteger(top) ||
      !Number.isInteger(left) ||
      !Number.isInteger(bottom) ||
      !Number.isInteger(right)
    ) {
      throw new Error("all query coordinates must be integers");
    }
    if (top >= bottom || left >= right) {
      throw new Error("query top cannot be greater than or equal to bottom");
    }
    if (left >= right) {
      throw new Error("query left cannot be greater than or equal to right");
    }

    const result = 0;
    for (let row = top; row < bottom; row++) {
      result += prefixSums[row][right] - (prefixSums[row][left - 1] || 0);
    }
    return result;
  });

  return queryResults;
}
```