#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e5+9;
typedef pair<int,int> pii;
int tot=0;
map<pii,int>mp;
vector<int> v[N];
int vis[N];
void dfs(int n){
for(auto it:v[n]){
if(vis[it]==0){
vis[it]=1;
dfs(it);
}
}
}
signed main(){
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
int a,b,c,d;
cin>>a>>b>>c>>d;
if(mp[{a,b}]==0){
mp[{a,b}]=tot++;
}
if(mp[{c,d}]==0){
mp[{c,d}]=tot++;
}
v[mp[{c,d}]].push_back(mp[{a,b}]);
v[mp[{a,b}]].push_back(mp[{c,d}]);
}
int sum=0;
for(int i=0;i<tot;i++){
if(vis[i]==0){
dfs(i);
sum++;
}
}
if(sum<=m){
cout<<"yes";
}
else {
cout<<"no\n";
cout<<sum-m;
}
return 0;
}
|