#K79512. Consistent Supply Kits

    ID: 35325 Type: Default 1000ms 256MiB

Consistent Supply Kits

Consistent Supply Kits

You are given several supply kits, each represented as a string of characters where each character indicates an item.

Two kits are considered consistent if they contain exactly the same items in the same quantities, regardless of their order. In other words, if the frequency of every item in one kit matches that in any other kit, the kits are consistent. Otherwise, they are inconsistent.

The input begins with an integer n which indicates the number of supply kits. This is followed by n lines where each line represents a supply kit.

Your task is to determine whether all the kits are consistent. If they are, output True; otherwise, output False.

Note: An empty list of kits, i.e. when n = 0, is considered consistent.

The consistency condition can be formulated mathematically as follows:

Let \(S_1, S_2, \dots, S_n\) be the kits, and let \(f_i(c)\) denote the frequency of character \(c\) in kit \(S_i\). Then the kits are consistent if and only if \[ \forall i, j, \; f_i(c) = f_j(c) \quad \text{for all characters } c. \]

inputFormat

The first line contains an integer n, representing the number of supply kits. Each of the following n lines contains a non-empty string that represents a supply kit.

outputFormat

Output a single line: True if all the supply kits are consistent, and False otherwise.## sample

3
WWFFMM
MMFFWW
WWMMFF
True

</p>