#include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define rep(i,n) for (int i=0;i < (int)(n);i++) class union_find { public: vector par,rank,lsize; union_find(int n): par(n),rank(n),lsize(n){ for (int i=0;i < n;i++){ par[i]=i; rank[i]=0; lsize[i]=1; } } int find(int x){ if (par[x]==x){ return x; } else{ return par[x] = find(par[x]); } } void unite(int x ,int y){ x=find(x); y=find(y); if (x==y) return; if (rank[x] < rank[y]){ lsize[y] += lsize[x]; lsize[x] = -1; par[x] = y; }else{ lsize[x] += lsize[y]; lsize[y] = -1; par[y]=x; if (rank[x]==rank[y]) rank[x]++; } } bool same(int x, int y){ return find(x) == find(y); } int size(int x){ if (lsize[x] == -1){ x=find(x); } return lsize[x]; } int groups(){ int res = 0; for (int i = 0;i < par.size();i++){ if (i == par[i]) res++; } return res; } }; void solve(){ int n,m; cin >> n >> m; union_find d(2*n); for (int i = 0; i < m;i++){ int a,b; cin >> a >> b; a--;b--; d.unite(a,b+n); d.unite(a+n,b); } if (d.groups() == 1){ cout << "Yes\n"; } else cout << "No\n"; return; } int main(){ int tt = 1; //cin >> tt; while(tt--){ solve(); } return 0; }