<|instruction|>
Solve the below problem. The solution should start with an abridged problem statement. Then key observations. Then full solution based on the observations. Then C++ and Python implementations with comments.

172. eXam
time limit per test: 0.25 sec.
memory limit per test: 4096 KB
input: standard
output: standard



In Russia school pupils must do some exams before leaving school. Among others, they must do two "selective" exams. This means that school provides a list of available subjects; each pupil selects two different subjects from this list and is going to do this exams. According to rules, pupil isn't allowed to do both exams at the same day, so the school must schedule the exams, i.e. provide some days when pupils will be able to do exams.

One school does not want to warn teachers too much. They want to schedule all the exams into two days in such way that exams on some subjects are on the first day, and exams on all other (and only on them) are on second. You are to write a program, which will determine, if it is possible to schedule exams in this way so that all pupils will be able to do all their selected exams.

Input
On the first line of input there are two integers N and M (1<=N<=200, 1<=M<=30000) - the number of available subjects and the number of pupils. Then M lines follows; on i-th of them there are two integers - the numbers of exams, which were selected by i-th pupil. Exams are numerated from 1 to N.

Output
If the solution exists, write on the first line of output only one word "yes". On the second line write the total number of exams, which must be held on first day, and on the third line - the numbers of subjects of this exams. If there exist several solutions, output any. If no solution exists, write to output only one word "no".

Sample test(s)

Input
4 4
1 2
3 4
2 4
1 3

Output
yes
2
1 4
Author:	NNSU#2 team
Resource:	Lazurny olympiad in informatics
Date:	July-August 2002

<|response|>
1. Abridged problem statement  
   Given N subjects (numbered 1…N) and M pupils, each pupil chooses exactly two different subjects. We must assign each subject to one of two days (Day 1 or Day 2) so that no pupil has both of their chosen exams on the same day. If such an assignment exists, print “yes,” the number of subjects on Day 1, and the list of those subjects; otherwise print “no.”

2. Key observations  
   • Each subject can be viewed as a vertex in an undirected graph.  
   • Each pupil selecting subjects u and v imposes an edge (u,v) meaning u and v must be on different days.  
   • We need to label vertices with two “colors” (day 1 vs. day 2) so that every edge joins vertices of opposite colors.  
   • A graph is 2-colorable in this way exactly when it is bipartite.  
   • Checking bipartiteness and constructing a 2-coloring can be done by BFS or DFS in O(N + M).

3. Full solution approach  
   a) Read N and M.  
   b) Build an adjacency list adj of size N, then for each pupil’s pair (u,v) add v to adj[u] and u to adj[v], converting to 0-based indices.  
   c) Create an array color[0…N−1], initialized to −1 (meaning “unvisited”).  
   d) For each vertex i from 0 to N−1, if color[i] is −1, do a BFS from i:  
      – Assign color[i] = 0 and push i into a queue.  
      – While the queue is not empty, pop a vertex u. For each neighbor v in adj[u]:  
        • If color[v] is −1, set color[v] = 1 − color[u] and enqueue v.  
        • If color[v] == color[u], there is a conflict → graph is not bipartite → print “no” and exit.  
   e) If all components are processed with no conflict, the graph is bipartite. Collect all vertices i with color[i] == 0 (these will go on Day 1).  
   f) Print “yes,” then the size of this Day-1 list, then the list of these subject numbers in 1-based form.

4. C++ implementation with detailed comments  
```cpp
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, M;
    // Read number of subjects N and number of pupils M
    cin >> N >> M;

    // Build adjacency list for N subjects (0-based)
    vector<vector<int>> adj(N);
    for (int i = 0; i < M; i++) {
        int u, v;
        cin >> u >> v;
        // convert to 0-based indices
        u--; 
        v--;
        // add undirected edge
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    // color[i] = -1 means unvisited; 0 or 1 are the two days
    vector<int> color(N, -1);

    // Function to check bipartiteness via BFS from a start vertex
    auto bfs_check = [&](int start) {
        queue<int> q;
        color[start] = 0;
        q.push(start);
        while (!q.empty()) {
            int u = q.front();
            q.pop();
            for (int v : adj[u]) {
                if (color[v] == -1) {
                    // assign opposite color
                    color[v] = 1 - color[u];
                    q.push(v);
                }
                else if (color[v] == color[u]) {
                    // same color on both ends => not bipartite
                    return false;
                }
            }
        }
        return true;
    };

    // Check all components
    for (int i = 0; i < N; i++) {
        if (color[i] == -1) {
            if (!bfs_check(i)) {
                cout << "no\n";
                return 0;
            }
        }
    }

    // If we reach here, graph is bipartite
    // Collect all subjects assigned color 0 → Day 1
    vector<int> day1;
    for (int i = 0; i < N; i++) {
        if (color[i] == 0) {
            day1.push_back(i + 1);  // convert back to 1-based
        }
    }

    cout << "yes\n";
    cout << day1.size() << "\n";
    for (int subj : day1) {
        cout << subj << " ";
    }
    cout << "\n";

    return 0;
}
```

5. Python implementation with detailed comments  
```python
import sys
from collections import deque

def main():
    data = sys.stdin.read().split()
    it = iter(data)
    # Number of subjects, number of pupils
    n = int(next(it))
    m = int(next(it))

    # Build adjacency list (0-based)
    adj = [[] for _ in range(n)]
    for _ in range(m):
        u = int(next(it)) - 1
        v = int(next(it)) - 1
        adj[u].append(v)
        adj[v].append(u)

    # color[i] = -1 means unvisited; 0/1 are the two days
    color = [-1] * n

    # BFS to check bipartiteness from a given start vertex
    def bfs(start):
        queue = deque([start])
        color[start] = 0
        while queue:
            u = queue.popleft()
            for v in adj[u]:
                if color[v] == -1:
                    color[v] = 1 - color[u]
                    queue.append(v)
                elif color[v] == color[u]:
                    # Conflict found
                    return False
        return True

    # Process each connected component
    for i in range(n):
        if color[i] == -1:
            if not bfs(i):
                print("no")
                return

    # If bipartite, gather all subjects colored 0 for Day 1
    day1 = [i + 1 for i in range(n) if color[i] == 0]
    print("yes")
    print(len(day1))
    print(*day1)

if __name__ == "__main__":
    main()
```