#K6151. Eulerian Cycle Trail Check

    ID: 31325 Type: Default 1000ms 256MiB

Eulerian Cycle Trail Check

Eulerian Cycle Trail Check

You are given an undirected graph representing a network of trails connecting waypoints. The graph has M vertices (numbered from 1 to M) and N trails. The trails are added one by one in the given order. After each trail is added, you need to determine whether it is possible to form an Eulerian cycle that starts and ends at the base camp (vertex 1).

An Eulerian cycle in an undirected graph exists if and only if:

  • The base camp (vertex 1) has at least one incident trail.
  • All vertices with a nonzero degree lie in a single connected component.
  • Every vertex with a nonzero degree has an even degree, i.e., for every vertex v, \( deg(v) \) is even.

For each trail addition, if the current set of trails satisfies the conditions for the existence of an Eulerian cycle, output Yes; otherwise, output No.

inputFormat

The first line contains two integers M and N — the number of vertices and the number of trails added, respectively.

The next N lines each contain two integers u and v representing a trail between vertices u and v.

Input is provided via standard input (stdin).

outputFormat

Output N lines. The i-th line should contain either Yes or No depending on whether an Eulerian cycle starting and ending at vertex 1 is possible after adding the first i trails.

Output is to be written to standard output (stdout).

## sample
4 4
1 2
2 3
3 1
1 4
No

No Yes No

</p>