function to check if a query interval is covered by a set of intervals