Implement a rudimentary geospatial partitioning scheme using R-trees. Build a bulk-loaded R-tree over axis-aligned rectangles, then answer each axis-aligned rectangle query by returning the intersecting rectangle IDs in their original input order. Use inclusive intersection, so rectangles or boundaries that touch count as intersecting.
Implement spatial_queries(rectangles, queries). Each rectangle is [id, x1, y1, x2, y2], each query is [x1, y1, x2, y2], and coordinates satisfy x1 <= x2 and y1 <= y2. Return one list of IDs per query. An empty rectangle collection is valid.
def spatial_queries(rectangles, queries):