In an alternate universe, every person has a three-letter name, and each letter must have a distinct reading. For example, "JWS" is a valid name, but "JW" is not because it has only two letters, and "JWJ" is not a valid name because two of the letters are same.That is, for the letters 'A', 'B' and 'C', each letter is contained in the names of at least two people.Now, you have a library of nnn unique letters, and each letter can be used aia_iai times, with the total number of uses of all letters guaranteed to be a multiple of 3. You can create sum/3sum/3sum/3 people names with them, where sumsumsum is the sum of all aia_iai. Please determine the maximum number of name groups you can create. If it is impossible to create sum/3sum/3sum/3 valid name groups, output -1.
In an alternate universe, every person has a three-letter name, and each letter must have a distinct reading. For example, "JWS" is a valid name, but "JW" is not because it has only two letters, and "JWJ" is not a valid name because two of the letters are same. If there are three people whose names have a magical characteristic, we call them a "name group". The characteristics of a name group are as follows: you can choose three different letters such that each letter is contained in the names of at least two people in the group. For example, if the first person is named "ACD", the second person is named "ABE", and the third person is named "BCF", then selecting "A" would include the first two people, selecting "C" would include the first and third people, and selecting "B" would include the second and third people. (Only the inclusion of a letter is necessary, not the position of the letter in the name.) That is, for the letters 'A', 'B' and 'C', each letter is contained in the names of at least two people. Note: each person can only be in one name group, and different people can have the same name. Now, you have a library of nnn unique letters, and each letter can be used aia_iai times, with the total number of uses of all letters guaranteed to be a multiple of 3. You can create sum/3sum/3sum/3 people names with them, where sumsumsum is the sum of all aia_iai. Please determine the maximum number of name groups you can create. If it is impossible to create sum/3sum/3sum/3 valid name groups, output -1.