Given $$$n$$$ strings $$$w_1, w_2, \cdots, w_n$$$, please select $$$k$$$ strings among them, so that the lexicographic order of string $$$v$$$ is minimized, and output the optimal string $$$v$$$. String $$$v$$$ satisfies the following constraint: $$$v$$$ is the longest common prefix of two selected strings with different indices. Also, $$$v$$$ is the lexicographically largest string among all strings satisfying the constraint.
More formally, let $$$\mathbb{S}$$$ be a set of size $$$k$$$, where all the elements in the set are integers between $$$1$$$ and $$$n$$$ (both inclusive) and there are no duplicated elements. Let $$$\text{lcp}(w_i, w_j)$$$ be the longest common prefix of string $$$w_i$$$ and $$$w_j$$$, please find a set $$$\mathbb{S}$$$ to minimize the lexicographic order of the following string $$$v$$$ and output the optimal string $$$v$$$.
$$$$$$ v = \max\limits_{i \in \mathbb{S}, j \in \mathbb{S}, i \ne j} \text{lcp}(w_i, w_j) $$$$$$
In the above expression, $$$\max$$$ is calculated by comparing the lexicographic order of strings.
Recall that:
There are multiple test cases. The first line of the input contains an integer $$$T$$$ indicating the number of test cases. For each test case:
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2\leq n\leq 10^6$$$, $$$2\leq k\leq n$$$) indicating the total number of strings and the number of strings to be selected.
For the following $$$n$$$ lines, the $$$i$$$-th line contains a string $$$w_i$$$ ($$$1\leq |w_i|\leq 10^6$$$) consisting of lower-cased English letters.
It's guaranteed that the total length of all strings of all test cases will not exceed $$$10^6$$$.
For each test case output one line containing one string indicating the answer. Specifically, if the answer is an empty string, print EMPTY.
25 3gdcpcgdcpcpcpsuasuasuassususua3 3abc
gdcpc EMPTY