#K36182. Team Division with Rivalries

    ID: 25698 Type: Default 1000ms 256MiB

Team Division with Rivalries

Team Division with Rivalries

You are given n teams and m pairs of rivalries. Your task is to determine whether it is possible to form two disjoint groups, each consisting of exactly 4 teams, such that in each group no two teams are rivals.

More formally, given an integer \(n\) and an integer \(m\) along with \(m\) pairs \((a_i, b_i)\) denoting rivalries between team \(a_i\) and team \(b_i\), check if there exist two subsets \(G_1\) and \(G_2\) of the teams such that:

  • \(|G_1| = |G_2| = 4\);
  • \(G_1 \cap G_2 = \emptyset\);
  • For each group and for every pair of teams within the group, there is no rivalry between them.

If such groups exist, output Possible, otherwise output Impossible.

Note: If \(n < 8\), it is automatically impossible to form two groups of 4 teams.

inputFormat

The input is read from stdin and has the following format:

 n m
 a1 b1
 a2 b2
 ...
 am bm

where:

  • \(n\) is the total number of teams.
  • \(m\) is the number of rivalry pairs.
  • Each of the next \(m\) lines contains two integers \(a_i\) and \(b_i\) denoting a pair of rival teams.

outputFormat

Output a single line to stdout containing either Possible if two disjoint valid groups can be formed, or Impossible otherwise.

## sample
8 3
1 2
3 4
5 6
Possible