3 5
2 1 608591421 720962564
3 2 608591421 641991574
3 2 718110706 353409763
2 3 482786015 858341723
3 2 825397574 357507279
 2 1
2 1 317425595 636156322
 50000 1
20845 28516 904146168 997637433

Yes
641991574 1
2 
 Yes
0 0

 Yes
0 0


#include <bits/stdc++.h>
#define fto(i,a,b) for(int i=a; i<=b;++i)
#define fdto(i,a,b) for(int i=a; i>=b;--i)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<ll,ll>
#define ll long long
#define maxn 50009
#define gb(i,j) ((i>>j)&1)
#define name "a"
#define endl '\n'
#define int ll
using namespace std;
int s1[3],s[3],xd[maxn],x[maxn],y[maxn],c[maxn],t[maxn],kt[maxn],m,n;
vector<int> a[maxn];
void dfs(int j,int cs){
    int k=(cs>0?1:2);
    ++s1[k];
    xd[j]=cs;
    s[k]=max(s[k],t[j]);
    for(int v:a[x[j]])
    if(v!=j){
        if(xd[v]==0)dfs(v,-cs);
        else if(xd[v]!=-cs){
            cout << "No";
            exit(0);
        }
    }
    for(int v:a[y[j]])
    if(v!=j){
        if(xd[v]==0)dfs(v,-cs);
        else if(xd[v]!=-cs){
            cout << "No";
            exit(0);
        }
    }
}
pii b[maxn];
main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen(name".inp","r", stdin);
    freopen(name".out","w", stdout);
    #endif // ONLINE_JUDGE
    cin >> n >> m;
    fto(i,1,m){
        cin >> x[i] >> y[i] >> c[i] >> t[i];
        b[i]=mp(c[i],i);
    }
    sort(b+1,b+m+1);
    b[m+1].fi=-1;
    int res1=0,res=0,tplt=0;
    for(int i=1; i<=m; +i){
        int xx=b[i].fi,j=i;
        vector<int> vec;
        while(b[i].fi==xx){
            int j=b[i++].se;
            vec.pb(x[j]);
            vec.pb(y[j]);
            a[x[j]].pb(j);
            a[y[j]].pb(j);
            if(a[x[j]].size()>2){cout << "No";return 0;}
            if(a[y[j]].size()>2){cout << "No";return 0;}
        }
        for(;j<i; ++j)
        if(xd[b[j].se]==0){
            s[1]=s[2]=0;
            s1[1]=s1[2]=0;
            dfs(b[j].se,++tplt);
            if(s[1]<s[2]){
                kt[tplt]=1;
                res=max(s[1],res);
                res1+=s1[1];
            }
            else{
                kt[tplt]=2;
                res=max(s[2],res);
                res1+=s1[2];
            }
        }
        for(int x:vec)a[x].clear();
    }
    cout << "Yes\n";
    cout << res <<' '<< res1 <<endl;
    for(int i=1; i<=m; ++i){
        int t=(xd[i]>0?1:2);
        int j=kt[abs(xd[i])];
        if(t==j) cout << i <<' ';
    }
    return 0;
}
