User information leaked from the popular social network Secret Network. The leaked data holds the passwords of every user.
Mihael, a student who has been studying computer security, found the whole affair interesting. While poking around the social network he found one more hole. If you type any string that contains a substring equal to the real password, the login succeeds. For example, a user whose password is abc is logged in after typing abc, abcd or imaabcnema, while axbc fails.
Mihael wants to know how many ordered pairs of two different users there are such that the first user, typing their own password, can log in as the second user.