Under construction

Still being built. Things may change

Pipe cleaning

Time limit7sMemory limit256 MB

Summary
Decide whether a subset of pipes covers every pipe crossing with exactly one of the two crossing pipes chosen.
Level

Medium6 of 10

Topics
Graph, BFS, Geometry
Solved
No attempts yet

Problem

The water utility of Linköping draws groundwater from several wells outside the city. Each pipe runs in a straight line from one well to a point in the city.

All pipes lie at the same depth, so two pipes that meet create a junction at that spot. Exactly two pipes meet at any junction. A well does not count as a junction, and a well may start zero or more pipes.

Debris builds up at junctions, strains the pipes, and eventually opens a sinkhole. The company that runs the water supply designed a cleaning robot to stop that. When a robot is inserted at a well into one pipe, it travels that pipe to the end and back, cleaning every junction on the pipe. To keep two robots from colliding, the rules say that at each junction where two pipes meet, only one of those two pipes may contain a robot.

The water supply is shut off while cleaning runs, so the company wants to finish in one pass. Decide whether robots can be inserted into some subset of the pipes at the same time so that every junction is cleaned and the rule holds.

Input

The first line contains the number of wells ww and the number of pipes pp. (1≤w≤10001 \le w \le 1000, 1≤p≤10001 \le p \le 1000)

Each of the next ww lines contains xix_i and yiy_i, the coordinates of well ii. (−10000≤xi,yi≤10000-10000 \le x_i, y_i \le 10000) The wells are numbered 1 through ww in that order.

Each of the next pp lines contains three integers ss, xx, yy. (1≤s≤w1 \le s \le w, −10000≤x,y≤10000-10000 \le x, y \le 10000) This means a pipe starts at well ss and ends at the point (x,y)(x, y).

The only well a pipe passes through is its own starting point. Every point where three or more pipes meet is a well. Two pipes share at most one point, and that point may be an endpoint of a pipe. Every pipe has positive length.

Output

Print possible on one line if such a subset exists, and impossible otherwise.

Examples2

  1. Example 1

    Input
    3 3
    0 0
    0 2
    2 0
    1 2 3
    2 2 2
    3 0 3
    
    Expected output
    impossible
    
  2. Example 2

    Input
    2 3
    0 0
    0 10
    1 5 15
    1 2 15
    2 10 10
    
    Expected output
    possible