This page is still under construction.

Parts of this page are still being built. What you see may change.

Basin City Surveillance

Time limit2sMemory limit256 MB

Summary
Decide whether k vertices can be chosen so no two are adjacent in a graph of degree at most four.
Level

Medium7 of 10

Topics
Backtracking, Graph, Brute force
Solved
No attempts yet

Problem

BASIN CITY has a very high crime rate. The police are tightening security and want to install traffic drones at intersections to watch for cars running a red light. When a car runs a red light, the drone at that intersection chases the car, stops it, and gives the driver a ticket.

The drones are not smart. A drone breaks off a chase before it reaches the next intersection, because any farther out it would lose the way back to its home, the traffic light it is assigned to. A drone also cannot detect another drone, so the police R&D department concluded that once a drone sits at an intersection, no drone should be placed at an intersection joined to it by a road. As in many other cities, no intersection in BASIN CITY has more than four neighbouring intersections.

The government pays for the drones, so the police want to buy as many as they are allowed to. Given the number of drones kk, decide whether exactly kk drones can be placed so that no two of them sit at neighbouring intersections.

Input

The first line contains the number of drones to place, kk (0≤k≤150 \le k \le 15). The second line contains the number of intersections in BASIN CITY, nn (1≤n≤100 0001 \le n \le 100\,000). The next nn lines describe the intersections in order. The ii-th of those lines starts with an integer dd, the number of intersections neighbouring intersection ii (0≤d≤40 \le d \le 4), followed by the dd indices of those neighbours. The indices are distinct and different from ii. The intersections are numbered from 1 to nn.

Output

Print possible on a single line if kk drones can be placed so that no two neighbouring intersections both hold a drone. Otherwise print impossible.

Examples2

  1. Example 1

    Input
    4
    7
    2 2 4
    3 1 3 5
    1 2
    2 1 5
    4 2 6 4 7
    2 5 7
    2 6 5
    
    Expected output
    impossible
    
  2. Example 2

    Input
    4
    8
    2 2 4
    3 1 3 5
    1 2
    2 1 5
    4 2 6 4 7
    2 5 8
    2 8 5
    2 7 6
    
    Expected output
    possible