#K52872. Hackathon Feasibility Allocation

    ID: 29406 Type: Default 1000ms 256MiB

Hackathon Feasibility Allocation

Hackathon Feasibility Allocation

You are given n cities and m sponsors. Each city has a certain number of hackers that require support during hackathons. Each sponsor supports several cities with a specified limit. For a sponsor, if the support limit offered for a city is greater than or equal to the number of hackers in that city, then that sponsor can contribute to that city.

Your task is to determine whether every city can receive support from at least one sponsor. In other words, check if for every city there exists at least one sponsor whose specified support limit for that city is not less than the required number of hackers.

The input will be provided via standard input (stdin) and the output should be printed to standard output (stdout). Use the following rules:

  • The first line contains two integers: n (number of cities) and m (number of sponsors).
  • The second line contains n integers indicating the number of hackers in each city.
  • The next m lines each represent a sponsor. Each sponsor line starts with an integer c indicating the number of supported cities, followed by 2*c integers representing c pairs of (city_index, support_limit).

If every city is supported by at least one sponsor (i.e. there exists at least one sponsor for which the city's hacker count is less than or equal to the provided support limit), print POSSIBLE. Otherwise, print IMPOSSIBLE.

All formulas are presented in LaTeX format. For instance, the requirement for a city's hacker count is given as:

\(\text{hackers}[i] \leq \text{limit}\).

inputFormat

The input is read from standard input (stdin) and has the following structure:

  1. The first line contains two space-separated integers: n and m.
  2. The second line contains n space-separated integers which represent the number of hackers in each city.
  3. The next m lines each correspond to a sponsor's data. Each of these lines begins with an integer c indicating the number of supported cities, followed by 2*c integers representing (city_index, support_limit) pairs.

outputFormat

Output a single line to standard output (stdout) containing either POSSIBLE if every city can obtain sponsorship, or IMPOSSIBLE otherwise.

## sample
3 2
10 20 30
2 1 15 2 20
1 3 40
POSSIBLE