Under construction

Still being built. Things may change

Gather at one point

Time limit5sMemory limit512 MB

Summary
For each query [l, r], find the minimum sum of Chebyshev distances from the people l..r to a freely chosen point.
Level

Medium7 of 10

Topics
Prefix sum, Divide and conquer, Math, Sorting
Solved
No attempts yet

Problem

NN people stand on a two dimensional plane. The people are numbered from 1 to NN.

The distance between two points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is max⁡(∣x1−x2∣,∣y1−y2∣)\max(|x_1 - x_2|, |y_1 - y_2|).

Write a program that answers the following query.

  • l r: person ll through person rr gather at a single point PP on the plane. Print the minimum possible sum of the distances between each of those people and PP.

The point PP can be anywhere on the plane, and its coordinates do not have to be integers.

Input

The first line contains the number of people NN and the number of queries QQ, separated by a space. (1≤N,Q≤100 0001 \le N, Q \le 100\,000)

Each of the next NN lines contains the coordinates XiX_i and YiY_i of person ii, separated by a space. (−1 000 000 000≤Xi,Yi≤1 000 000 000-1\,000\,000\,000 \le X_i, Y_i \le 1\,000\,000\,000)

Each of the next QQ lines contains LiL_i and RiR_i of a query, separated by a space. (1≤Li≤Ri≤N1 \le L_i \le R_i \le N)

Output

Print the answer to each query on its own line, in the order the queries are given.

The answer is always a multiple of 0.50.5, so print it with exactly one digit after the decimal point. Print 5.0 for an answer of 55 and 8.5 for an answer of 8.58.5.

Hint

In the first example, the first query is minimized by gathering at (1.5,2.5)(1.5, 2.5), and the second query is minimized by gathering at (1,1)(1, 1).

Examples2

  1. Example 1

    Input
    4 2
    1 4
    2 3
    0 1
    1 1
    1 4
    3 4
    
    Expected output
    5.0
    1.0
    
  2. Example 2

    Input
    3 3
    0 0
    1 0
    0 1
    1 3
    1 2
    2 2
    
    Expected output
    1.5
    1.0
    0.0