Queries

No attempts yetTime limit10sMemory limit128 MB

Problem

You are given a set of points Z and a tolerance value S. Write a program that processes two kinds of operations:

  • Remove: delete a given point from the set Z.
  • Find: report the "upper-left point" of the set Z.

The upper-left point is defined as follows. Let ymaxy_{\max} be the largest yy-coordinate among the points currently in Z. Consider as candidates every point whose yy-coordinate is smaller than ymaxy_{\max} by at most S, that is, every point with yymaxSy \ge y_{\max} - S. Among the candidates, the upper-left point is the one with the smallest xx-coordinate (the leftmost one). If several candidates share the smallest xx-coordinate, choose the one with the largest yy-coordinate (the highest one).

Input

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

The first line of each test case contains two space-separated integers NN and SS (1N1051 \le N \le 10^5, 0S1090 \le S \le 10^9), the initial size of the set Z and the tolerance value. Each of the next NN lines contains two space-separated integers PXP_X and PYP_Y (109PX,PY109-10^9 \le P_X, P_Y \le 10^9), describing a point of Z. All points within one test case are distinct.

The next line contains an integer MM (1M21051 \le M \le 2 \cdot 10^5), the number of operations to perform. Each of the following MM lines has one of the two forms:

  • USUN PXP_X PYP_Y : remove the point (PX,PY)(P_X, P_Y) from the set Z.
  • ZNAJDZ : find the upper-left point.

A point named in a remove operation is guaranteed to be present in Z at that moment. A find operation is never issued while Z is empty.

Output

For every find (ZNAJDZ) operation, print the coordinates of the found point as x y on its own line.