Chess Tournament

Given reported chess results, decide whether some assignment of skill levels makes all results true, where equal skills draw and higher skill always wins.

Medium6Union-findGraphTopological sortNo attempts yetTime limit5sMemory limit512 MB

Problem

A friend of yours organizes an international chess championship. Players report their own match results to the jury, and the jury never confirms a report with the opponent. A player can therefore invent a match and report a win that never happened.

Chess is decided by skill, not by chance. A player with a higher skill level always beats a player with a lower one, and a game is a draw exactly when the two skill levels are equal. Nobody knows the skill level of any player.

Given the list of reported matches, decide whether the list is consistent. The list is inconsistent when at least one report can be shown to be false, that is, when no assignment of skill levels to players satisfies every report at once. Otherwise the list is consistent.

Input

The first line contains two integers NN and MM (2N500002 \le N \le 50000, 1M2500001 \le M \le 250000), the number of players and the number of reported matches.

Each of the next MM lines contains an integer KK, a symbol that is either = or >, and an integer LL (0K,L<N0 \le K, L < N). The integers KK and LL identify players. If the symbol is =, the game between KK and LL was a draw. If the symbol is >, then KK beat LL.

At most one match is reported between any given pair of players. Every player takes part in at least one reported match.

Output

Print a single line with a single word: consistent if every reported match can be true at the same time, and inconsistent if they cannot.