atcoder#ABC233H. [ABC233Ex] Manhattan Christmas Tree
[ABC233Ex] Manhattan Christmas Tree
Score : points
Problem Statement
There are Christmas trees in the two-dimensional plane. The -th tree is at coordinates .
Answer the following queries.
Query : What is the distance between and the -th nearest Christmas tree to that point, measured in Manhattan distance?
Constraints
- if .
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain the answer to Query .
4
3 3
4 6
7 4
2 5
6
3 5 1
3 5 2
3 5 3
3 5 4
100 200 3
300 200 1
1
2
2
5
293
489
The distances from to the -st, -nd, -rd, -th trees to that point are , , , , respectively. Thus, the answers to the first four queries are , , , , respectively.