Hermit Crabs

No attempts yetTime limit1sMemory limit128 MB

Problem

On many beaches you can see hermit crabs, which are quite interesting creatures. They are relatives of crabs, but have a soft belly, so to protect themselves they must live inside the empty shells of sea snails. What you actually see is a snail shell scurrying briskly along the beach; when you get close, the crab pulls itself inside and the shell looks like an ordinary shell, except that a big claw seals the entrance. Like most animals, hermit crabs grow over time, so sooner or later they must move to a bigger shell. A crab that cannot find a suitable shell is usually eaten very quickly, and when shells are scarce the crabs even fight one another for them. Here we determine which crabs survive as they outgrow their shells.

To keep things simple we assume the following.

  • Each hermit crab $i$ has an integer size $c_i \ge 0$. Because the crab grows, $c_i$ increases by $1$ every time unit, so at time $t$ its size is $c_i + t$.
  • Each shell $j$ has an integer size $s_j \ge 0$, which never changes.
  • For a given constant $D$, crab $i$ can live in shell $j$ at time $t$ if its size at that time satisfies $s_j - D \le c_i + t \le s_j$. (A shell that is too large cannot be sealed at the entrance; a shell that is too small does not fit.)
  • At time $0$, crab $i$ lives in shell $i$ (the input guarantees the sizes fit).
  • The instant a crab becomes too large for its current shell, that is, the instant its size exceeds $s_j$, it leaves that shell and moves into the largest currently unoccupied shell it can fit into. If no such shell exists at that instant, a bird eats it.
  • If several crabs try to move into the same shell at exactly the same instant, they fight, and only the largest crab wanting that shell survives; the others are eaten.
  • If a crab leaves shell $j$ at exactly the same instant another crab is looking for a shell, that other crab may move into shell $j$.

No two crabs ever have the same size, and no two shells ever have the same size, so every choice above is uniquely determined. Report which crabs are still alive at time $T$.

Input

The first line contains the number $K$ of data sets. Then follow $K$ data sets, each of the following form.

The first line of a data set contains four integers $n$, $m$, $D$, $T$: $n$ is the number of hermit crabs and $m$ the number of shells, with $1 \le n \le m \le 1000$; $D$ is the constant from the description; and $T$ is the length of the observation period.

The next $n$ lines each contain one integer $c_i$, the initial size of crab $i$ (all $c_i$ are distinct). The following $m$ lines each contain one integer $s_j$, the size of shell $j$ (all $s_j$ are distinct). The input guarantees $s_i - D \le c_i \le s_i$ for $i = 1, \dots, n$, so shell $i$ initially fits crab $i$.

Output

For each data set, first print a line Data Set x:, where $x$ is the data set number (starting from $1$). Then print, one per line and in increasing order, the indices of all crabs that are still alive at time $T$. Follow each data set with one blank line.