Dueling Philosophers#6213

Dueling Philosophers

1 second
64 megabytes
Very easy

After the discovery of a collection of unpublished essays, the philosophy department at a university wishes to publish them in a single volume. Each essay can define some terminology and use terms defined in other essays. There are constraints: if essay defines a term and essay uses it, then essay must come before in the arrangement.

Write a program to determine whether no arrangement, exactly one arrangement, or multiple arrangements of the essays is possible under these constraints.

Input

There will be multiple test cases in the input. Each test case begins with a line containing two integers (1 \le n \le 1000) and (1 \le m \le 500000), the number of essays and the number of constraints, respectively. The following lines each contain two integers and (1 \le d, u \le n, d \ne u), meaning that essay must come before essay . The input ends with a line containing two 's.

Output

For each test case, output if no arrangement is possible, if exactly one arrangement is possible, or if more than one arrangement is possible. Do not output any extra spaces or blank lines between answers.

Examples

Example 1

Loading
Loading