Just like people, cows like to feel they are special in some way. Farmer John's cows all come from the same breed and look alike, so they measure uniqueness by their names.
Each cow's name contains a number of substrings. For example, "amy" has substrings {a, m, y, am, my, amy}, and "tommy" has substrings {t, o, m, y, to, om, mm, my, tom, omm, mmy, tomm, ommy, tommy}.
The uniqueness factor of a name is the number of distinct substrings of that name that appear in no other cow's name. If amy were alone in a herd, her uniqueness factor would be 6. If tommy were alone, his would be 14. With both cows in the same herd, amy's factor is 3 and tommy's factor is 11.
Given a herd of cows, compute each cow's uniqueness factor.