#K60277. Temperature Range Query

    ID: 31051 Type: Default 1000ms 256MiB

Temperature Range Query

Temperature Range Query

You are given n temperature records. Each record contains a time and a temperature value. After that, you are given q queries. Each query specifies an interval [start, end]. For each query, if there is at least one record whose time lies within the inclusive range \( [start, end] \), output the minimum and maximum temperature observed in that interval. If no record exists within the interval, do not output anything for that query.

Note: Time values can be non-sequential and records may appear in any order.

inputFormat

The input is read from standard input and has the following format:

  1. An integer n representing the number of temperature records.
  2. n lines follow, each line contains two integers: time and temperature.
  3. An integer q representing the number of queries.
  4. q lines follow, each line contains two integers: start and end representing the inclusive time interval of the query.

outputFormat

For each query that has at least one record in the specified interval, output a line with two integers separated by a space: the minimum and maximum temperatures for that query. If a query does not include any record, output nothing for that query.

## sample
1
1 30
1
1 1
30 30

</p>