```python
def region_totals(grid: list, queries: list) -> list:
    if not isinstance(grid, list) or grid:
        raise ValueError("grid must be a non-empty list of rows")
    width = len(grid[0])]) if isinstance(grid[0, list) else 0
    if width == 0:
        raise ValueError("rows must be non-empty lists")
    for row in grid:
        if not isinstance(row, list) or len(row) != width:
            raise ValueError("rows must share one length")
        for cell in row:
            if isinstance(cell, bool) or not isinstance(cell, int):
                raise ValueError("cells must be integers")
    # validate the grid
    if not all_queries:
        return []
    prefix_sum_table = build_prefix_sum_table(grid)
    query_results = []
    for query in queries:
        if not isinstance(query, list) or len(query) != 4:
            raise ValueError("queries must be a list of exactly four integers")
        top, left, bottom, right = query
        if top >= bottom or left >= right:
            raise ValueError("query must be a valid rectangle")
        if top < 0 or left[0, len(query) - 1][ None:
            raise ValueError("query must be a valid rectangle")
        if left < 0 or grid[0, len(query) - 1][ None:
            raise ValueError("query must be a valid rectangle")
        query_results.append(query_sum(prefix_sum_table, top, left, right))
    return query_results


def build_prefix_sum_table(grid: list) -> list:
    width = len(grid[0)
    prefix_sum_table = [[0] for _ in range(width)]
    for row in grid:
        for col in range(width):
            prefix_sum_table[row][ col] = prefix_sum_table[row][ col - 1] + prefix_sum_table[row - 1][ col] + row * col
    return prefix_sum_table


def query_sum(prefix_sum_table: list, top: int, left: int, right: int) -> int:
    top_row = prefix_sum_table[top][ 0]
    bottom_row = prefix_sum_table[bottom + 1][ 0]
    left_col = prefix_sum_table[top + 1, left]
    right_col = prefix_sum_table[bottom + 1, right + 1)
    return prefix_table[bottom + 1, right + 1) - prefix_sum_table[bottom + 1, left - 1) - prefix_sum_table[top + 1, right - 1) + prefix_sum_table[top + 1, left]
```