Wormholes#1108

Wormholes

1 second
128 megabytes
Medium

In the year 2163, wormholes were discovered. A wormhole is a tunnel through space and time connecting two star systems. Wormholes have the following properties:

A renowned physicist living on Earth wants to use wormholes to study the Big Bang theory. Since a warp drive has not yet been invented, it is not possible to travel directly between star systems. However, this can be done using wormholes.

The scientist wants to find a cycle of wormholes that will transport her into the past. By traveling along this cycle several times, she can reach the time of the Big Bang and witness it with her own eyes. Write a program to determine if such a cycle exists.

Input

The first line contains the number of star systems (1 \leq n \leq 1000) and the number of wormholes (0 \leq m \leq 2000). The star systems are numbered from (our solar system) to n - 1. Each wormhole is described on a separate line and contains three integers , , and . These numbers indicate that there is a wormhole from star system to star system , and traversing it changes the time by (-1000 \leq t \leq 1000) years.

Output

Output one line: "possible" if it is possible to go back in time infinitely using the given set of systems and wormholes, or "not possible" otherwise.

prb1108.gif

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading