#P2898. Hay Cow's Brain Game Consistency Check

    ID: 16156 Type: Default 1000ms 256MiB

Hay Cow's Brain Game Consistency Check

Hay Cow's Brain Game Consistency Check

The cows, who always have an inferiority complex about their intelligence, have devised a new guessing game to sharpen their brains. In this game, a designated Hay Cow hides behind the barn and creates N uniquely-sized stacks of hay bales (numbered from 1 to N), where each stack has between $1$ and $10^9$ hay bales.

The other cows then ask the Hay Cow a series of Q questions (with $1 \le Q \le 25000$). Each question is of the form:

"What is the smallest number of bales in any stack among stacks numbered \(Q_l\) to \(Q_h\) (with $1 \le Q_l \le N$ and $Q_l \le Q_h \le N$)?"

The Hay Cow answers each query with a single integer \(A\). However, the truthfulness of these answers is not guaranteed. Your task is to help the cows decide if the answers given by the Hay Cow are self‐consistent—i.e. it is possible to assign a distinct number of hay bales (each in the range $[1, 10^9]$) to the N stacks so that for every query the minimum number of bales in the designated range is exactly \(A\). Note that each query imposes two conditions on the stacks in its range \([Q_l, Q_h]\):

  • Every stack in the range must have at least \(A\) bales.
  • At least one stack in that range must have exactly \(A\) bales.

If such an assignment exists, output consistent; otherwise, output inconsistent.

inputFormat

The first line contains two space‐separated integers \(N\) and \(Q\) \( (1 \le N \le 10^6) \). Each of the following \(Q\) lines contains three space‐separated integers \(Q_l\), \(Q_h\), and \(A\) representing a query, where \(1 \le Q_l \le Q_h \le N\) and \(1 \le A \le 10^9\).

outputFormat

Output a single line containing either consistent if a valid assignment of stack sizes exists that meets all query requirements, or inconsistent otherwise.

sample

3 2
1 2 5
2 3 7
consistent