Meikyokan University is very famous for its research and education in the area of computer science. This university has a computer center that has advanced and secure computing facilities including supercomputers and many personal computers connected to the Internet.
One of the policies of the computer center is to let the students select their own login names. Unfortunately, students are apt to select similar login names, and troubles caused by mistakes in entering or specifying login names are relatively common. These troubles are a burden on the staff of the computer center.
To avoid such troubles, Dr. Choei Takano, the chief manager of the computer center, decided to stamp out similar and confusing login names. To this end, Takano has to develop a program that detects confusing login names.
Based on the following four operations on strings, the distance between two login names is determined as the minimum number of operations that transforms one login name to the other.
1. Deleting a character at an arbitrary position.
2. Inserting a character into 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" to "murai".
delete 'o' insert 'i'
omura ---------> mura --------> murai
Another example is that the distance between "akasan" and "kaason" is also two.
swap 'a' and 'k' replace 'a' with 'o'
akasan ---------------> kaasan -------------------> kaason
Takano decided that two login names with a small distance are confusing and thus must be avoided.
Your job is to write a program that enumerates all the confusing pairs of login names.
Beware that the rules may combine in subtle ways. For instance, the distance between "ant" and "neat" is two.
swap 'a' and 'n' insert 'e'
ant ---------------> nat ---------> neat