Hi! I'm Luffy! I'm the man who will become the Pirate King!

No attempts yetTime limit1sMemory limit128 MB

Problem

Hi! I'm Monkey D. Luffy, the man who's going to become the Pirate King! A few days ago we got our hands on a treasure map that marks the island where the legendary treasure, the One Piece, is hidden. Now we have to read this map and work out where the treasure island is.

The coast where the treasure island lies is dotted with a huge number of tiny islands, so searching them one by one would take far too long. This treasure map is unusual, though: it is not a bird's-eye view from above. Instead it records only which islands are seen, and in what order, when you stand on the peak of the treasure island and look out toward the sea in one direction.

Whoever drew it stood on the peak, faced a single direction with a $180$-degree forward field of view, and lined up every visible island from left to right. So an island drawn further to the left on the map really does appear further to the left from that vantage point. The artist was terrible, so the distances between islands do not match reality at all, and any island hidden by the thick fog was simply not drawn. Even so, the left-to-right order of the islands that were in view is exact, and every island carries a mark identifying which island it is.

Along with several such treasure maps, we also have a bird's-eye chart giving the exact position of every island on that coast. Each treasure map is given as a handful of facts of the form "island A appeared to the left of island B".

If we pick one island, stand on it, and face a suitable direction so that all islands appearing on that map fall within the $180$-degree forward field of view and every "island A is left of island B" fact holds, then that island is a possible treasure island. For each treasure map, find every island that could be the treasure island!

Input

The first line contains the number of test cases $T$. Each test case has the following format.

  • The first line contains the number of islands $n$. ($1 \le n \le 125000$)
  • Each of the next $n$ lines contains two integers $x_i$ and $y_i$, the coordinates of island $i$. ($0 < x_i, y_i < 2^{29}$)
  • The next line contains the number of treasure maps (queries) $k$ for this coast. Each treasure map is given as follows.
    • The first line contains the number of facts $m$. ($0 \le m \le 10000$)
    • Each of the next $m$ lines contains two integers $l$ and $r$ ($1 \le l, r \le n$, $l \ne r$), meaning that on that map island $l$ was drawn to the left of island $r$.

Within one coast, no two islands share the same $x$-coordinate, no two islands share the same $y$-coordinate, and no three islands are collinear.

Output

For each treasure map, print the numbers of the islands that could be the treasure island, one per line in ascending order. Then print a single integer $0$ on its own line to end the output for that map. If there is no possible treasure island, print only $0$.

Hint

The sample input describes the same situation as the map in the statement. From the given facts, the islands that could be the treasure island are islands $6$, $7$, and $8$ (Rummet, Alet, Schnaphpsum).