Confusing Login Names

Time limit3sMemory limit128 MB

Problem

Meikyokan University is very famous for its research and education in computer science. It has a computer center with advanced and secure computing facilities, including supercomputers and many personal computers connected to the Internet.

One policy of the computer center is to let students choose their own login names. Unfortunately, students tend to choose similar login names, and mistakes when typing or specifying a login name are relatively common. Such troubles are a burden on the center's staff.

To avoid them, Dr. Choei Takano, the chief manager of the computer center, decided to eliminate similar, confusing login names. To do so, Takano must develop a program that detects confusing login names.

Based on the following four operations on strings, the distance between two login names is defined as the minimum number of operations that transforms one login name into the other.

  1. Deleting a character at an arbitrary position.
  2. Inserting a character at an arbitrary position.
  3. Replacing a character at an arbitrary position with another character.
  4. Swapping two adjacent characters at an arbitrary position.

For example, the distance between "omura" and "murai" is two, because the following sequence of operations transforms "omura" into "murai".

omura → (delete 'o') → mura → (insert 'i') → murai

As another example, the distance between "akasan" and "kaason" is also two.

akasan → (swap 'a' and 'k') → kaasan → (replace 'a' with 'o') → kaason

Takano decided that two login names with a small distance are confusing and must be avoided.

Your job is to write a program that enumerates all confusing pairs of login names.

Beware that the rules may combine in subtle ways. For instance, the distance between "ant" and "neat" is two.

ant → (swap 'a' and 'n') → nat → (insert 'e') → neat

Input

The input consists of multiple datasets. Each dataset is given in the following format.

n
d
name1
name2
···
namen

The first integer $n$ is the number of login names. Then comes a positive integer $d$. Two login names whose distance is at most $d$ are deemed confusing. You may assume that $0 < n \le 200$ and $0 < d \le 2$. The $i$-th student's login name is given by $\text{name}_i$, which consists only of lowercase letters and has length less than $16$. You may assume that the names $\text{name}_i$ ($1 \le i \le n$) are all distinct.

The end of the input is indicated by a line that contains only a single zero.

Output

For each dataset, your program should output all pairs of confusing login names, one pair per line, followed by the total number of confusing pairs in the dataset.

In each pair, the two login names are separated by a single comma character (,), and the login name that alphabetically precedes the other appears first. The entire output of confusing pairs for each dataset must be sorted as follows: for two pairs "w1,w2" and "w3,w4", if w1 alphabetically precedes w3, or they are equal and w2 precedes w4, then "w1,w2" must appear before "w3,w4".