Don and Jan spend a lot of time together on the road, and to pass the time they play a game called Road Series. The goal is to find the number 1 on some sign, then 2, then 3, and so on. Multi-digit numbers must appear with their digits directly next to each other on a sign, and a single sign may supply several numbers.
For example, from a sign showing 678-43 15, they may use $67$, $78$, $43$, and $15$, but not $84$ (the two digits are separated by a dash) nor $31$ (separated by a space). They may also use the single digits $6$, $7$, $8$, $4$, $3$, $1$, $5$, and the three-digit number $678$. In general, a number is usable from a sign exactly when its digits appear as a contiguous block within the sign's text.
Requiring the numbers to be found strictly in order made the game very slow, so they relaxed it. Call $n$ the last complete number: the largest value such that every number from $1$ to $n$ has already been found. (Initially the last complete number is $0$.) They also allow themselves to remember numbers they have already seen that are not too far beyond $n$: specifically, they can remember any seen number in the window up to $n + w$, where $w$ is a fixed window size. A number that is greater than $n + w$ at the moment it is seen is not remembered.
For example, suppose $w = 4$ and the last complete number is $19$, so numbers up to $23$ can be remembered. On the sign Show time at 8:25, no one under 21 admitted, they can use the $21$ but not the $25$ (it exceeds $23$). If the next sign is The FleaBag Hotel, phone 555-2520, its $20$ makes $20$ complete and then $21$ (already remembered) complete, so the last complete number becomes $21$; now the window reaches $25$, and because $25$ also appears on that same sign, it can be used as well.
The first line contains an integer $m$, the number of test cases. Each test case begins with a line containing two positive integers $k$ and $w$, where $k$ ($k \le 1000$) is the number of signs and $w$ ($w \le 100$) is the window size. The next $k$ lines each contain the text of one sign. A sign's text may contain any combination of alphanumeric characters, punctuation, and spaces, and has length at most $1000$.
For each test case, output one line in the form Case i: n h, where $i$ is the test case number (starting from $1$), $n$ is the last complete number obtainable from that test case's signs, and $h$ is the highest number still remembered within the window (equal to $n$ when nothing beyond $n$ is remembered).