#include using namespace std; #define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++) #define rrep(i, r, l) for (int i = (int)(r); i > (int)(l); i--) #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() void solve() { int n, m; cin >> n >> m; vector> graph(2 * n, vector()); rep(i, 0, m) { int a, b; cin >> a >> b; a--; b--; graph[a].push_back(b + n); graph[b].push_back(a + n); graph[a + n].push_back(b); graph[b + n].push_back(a); } vector used(2 * n, -1); int now = 0; rep(i, 0, 2 * n) { if (used[i] != -1) { continue; } used[i] = now; queue q; q.push(i); while (!q.empty()) { int u = q.front(); q.pop(); for (auto v: graph[u]) { if (used[v] != -1) { continue; } used[v] = now; q.push(v); } } now++; } bool flag = true; rep(i, 0, n) { if (used[i] != used[i + n]) { flag = false; } } cout << (flag ? "Yes" : "No") << '\n'; } int main() { int q = 1; // cin >> q; while (q--) { solve(); } }