All problems

Problem 438

Euler Path or Circuit

Medium · 20 pts · Graph, Eulerian Circuit

Problem

An Euler path uses every edge of a graph exactly once; an Euler circuit is an Euler path that ends where it started. For an undirected graph with at least one edge, all nodes that have edges must be connected, and then: if every node has even degree, an Euler circuit exists; if exactly two nodes have odd degree, an Euler path (but no circuit) exists; otherwise neither exists. Nodes with no edges are ignored. Print CIRCUIT, PATH or NONE.

Input

First line: N and M. Next M lines: an edge u v (nodes labelled 1 to N; no repeated edges or self-loops).

Output

Print CIRCUIT, PATH or NONE.

Constraints

1 <= N <= 100000; 1 <= M <= 200000

Example input

3 3
1 2
2 3
3 1

Example output

CIRCUIT

Explanation

The edges 1-2, 2-3 and 3-1 form a triangle where every node has degree 2, so you can walk all three edges and return to the start: CIRCUIT.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Hamiltonian Path Next: Rat in a Maze Paths