#K36987. Divide Books into Two Groups
Divide Books into Two Groups
Divide Books into Two Groups
You are given a collection of N books and an integer M representing the total number of genres. Each book is associated with a genre (represented by an integer). The task is to determine if it is possible to split the books into two groups such that no two books of the same genre are in the same group.
In other words, for every genre ( i ) with count ( c_i ), the splitting is possible if and only if ( c_i \leq 2 ) for all ( i ). If any genre appears more than twice, then it is impossible to create such a partition.
Your program should read from standard input and output the answer to standard output.
inputFormat
The first line contains two space-separated integers: N (the number of books) and M (the number of genres).
The second line contains N space-separated integers, where the i-th integer represents the genre of the i-th book.
outputFormat
Output a single line: 'Possible' if the books can be divided into two groups according to the above conditions, otherwise output 'Impossible'.## sample
5 3
1 2 1 3 2
Possible