#include<iostream> #include<cstdio> usingnamespace std; constint N = 1e3 + 10; bool vis[N]; int n, m, sum, ans[N], match[N]; pair <int, int> k[N]; booldfs(int x) { if (!vis[k[x].first]) { vis[k[x].first] = true; if (match[k[x].first] == -1 || dfs(match[k[x].first])) { match[k[x].first] = x; returntrue; } } if (!vis[k[x].second]) { vis[k[x].second] = true; if (match[k[x].second] == -1 || dfs(match[k[x].second])) { match[k[x].second] = x; returntrue; } } } intmain() { cin >> n >> m; for (int i = 0; i < n; i++) match[i] = -1; for (int i = 0; i < m; i++) ans[i] = -1; for (int i = 0; i < m; i++) cin >> k[i].first >> k[i].second; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) vis[j] = false; if (!dfs(i)) break; sum++; } cout << sum << endl; for (int i = 0; i < n; i++) if (~match[i]) ans[match[i]] = i; for (int i = 0; i < m; i++) if (~ans[i]) cout << ans[i] << endl; return0; }