This page is still under construction.

Parts of this page are still being built. What you see may change.

Mine Clearing

Time limit10sMemory limit512 MB

Summary
Find the most mines covered by one axis-aligned 10 by 10 square placed anywhere on the site.
Level

Medium6 of 10

Topics
Sliding window, Sorting, Segment tree
Solved
No attempts yet

Problem

A new mine clearing machine has arrived at the site. One activation removes every mine inside a 10m × 10m square at once, and mines lying on the border of that square are removed as well. Two sides of the square are parallel to the x-axis and the other two are parallel to the y-axis, and the machine can be placed anywhere on the site.

The positions of all mines buried in the 10,000m × 10,000m site are known. Write a program that finds the largest number of mines one activation can remove.

Input

The first line contains the number of test cases TT (1≤T≤101 \le T \le 10).

The first line of each test case contains the number of mines NN (4≤N≤1000004 \le N \le 100000), and the next NN lines give the coordinates of the mines, one mine per line. Each of those lines holds two integers between 00 and 1000010000 separated by a single space, the x-coordinate first and the y-coordinate second. No two mines sit at the same coordinates, and a mine is small enough that its size can be ignored.

Output

For each test case, print on its own line the largest number of mines one activation can remove.

Examples1

  1. Example 1

    Input
    3
    4
    10 10
    20 20
    30 30
    40 40
    15
    36 33
    15 27
    35 43
    42 36
    21 49
    27 12
    9 40
    26 13
    26 40
    36 22
    18 11
    29 17
    30 32
    23 12
    35 17
    27
    40 10
    26 11
    6 13
    53 15
    18 16
    23 18
    33 16
    42 20
    10 21
    3 27
    6 43
    13 37
    16 27
    15 46
    23 26
    23 49
    30 23
    30 37
    33 47
    37 23
    40 40
    46 48
    40 29
    43 28
    49 25
    46 30
    44 33
    
    Expected output
    2
    5
    5