#K7706. Equal Distribution of Book Genres

    ID: 34780 Type: Default 1000ms 256MiB

Equal Distribution of Book Genres

Equal Distribution of Book Genres

Emma is an avid reader with books from various genres. She wants to ensure that every month, she reads an equal number of books from each genre she owns. Given a collection of books described by their genres, your task is to determine whether the books can be evenly distributed such that every available genre appears the same number of times.

Formally, for each test case you are given an integer \(N\) (the total number of books) and a list of \(N\) integers \(G_1, G_2, \ldots, G_N\), where each \(G_i\) is the genre of the \(i\)-th book. You need to check if all the genres present in the list occur the same number of times. If they do, output Possible; otherwise, output Not Possible.

Example:

For \(N = 6\) and genres [1, 2, 2, 1, 1, 2], the frequency of genre 1 is 3 and genre 2 is 3, so the answer is Possible.

inputFormat

The first line of input contains a single integer \(T\) representing the number of test cases. Each test case has two lines:

  • The first line contains an integer \(N\), the number of books.
  • The second line contains \(N\) space-separated integers \(G_1, G_2, \ldots, G_N\) where each \(G_i\) represents the genre of the \(i\)-th book.

outputFormat

For each test case, output a single line containing either Possible if all the genres occur the same number of times, or Not Possible otherwise.

## sample
1
6
1 2 2 1 1 2
Possible

</p>