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


import java.util.*;
import java.io.*;
public class D{
    static PrintWriter out;
    static InputReader in;
    public static void main(String args[]){
        out = new PrintWriter(System.out);
        in = new InputReader();
        new D();
        out.flush(); out.close();
    }   
    D(){
        solve();
    }
    final long max = (long)(1E14);
    int n, m, c[]; pair ja[][];
    int from[], to[], co[], t[], f1[], t1[];
    pair bs(int u, int co){
        int l = 0, r = c[u] - 1;
        int L = 0, R = -1;
        while(l <= r){
            int m = (l + r) >> 1;
            if(ja[u][m].S >= co){
                r = m - 1;
                if(ja[u][m].S == co)L = m; 
            }else{
                l = m + 1;
            }
        }
        l = 0; r = c[u] - 1;
        while(l <= r){
            int m = (l + r) >> 1;
            if(ja[u][m].S <= co){
                l = m + 1;
                if(ja[u][m].S == co)R = m; 
            }else{
                r = m - 1;
            }
        }
        return new pair(L, R);
    }
    void solve(){
        n = in.nextInt(); m = in.nextInt();
        c = new int[n + 1]; ja = new pair[n + 1][]; from = new int[m]; to = new int[m]; co = new int[m]; t = new int[m];
        for(int i = 0; i < m; i++){
            int u = in.nextInt(), v = in.nextInt(); co[i] = in.nextInt(); t[i] = in.nextInt();
            from[i] = u; to[i] = v; 
            c[u]++; c[v]++; 
        }
        for(int i = 1; i <= n; i++){
            ja[i] = new pair[c[i]]; c[i] = 0;
        }
        for(int i = 0; i < m; i++){
            ja[from[i]][c[from[i]]++] = new pair(i, co[i]);
            ja[to[i]][c[to[i]]++] = new pair(i, co[i]);
        }
        for(int i = 1; i <= n; i++){
            Arrays.sort(ja[i], (A, B) -> A.S - B.S);
        }

        f1 = new int[2 * m]; t1 = new int[2 * m];
        int e = 0;

        for(int i = 0; i < m; i++){
            int u = from[i], v = to[i];
            pair r1 = bs(u, co[i]), r2 = bs(v, co[i]);
            int tot = r1.S - r1.F + r2.S - r2.F + 1;
            // System.out.println(r1.F + " " + r1.S + " " + r2.F + " " + r2.S);
            if(tot > 3){
                out.println("No"); return;
            }
            for(int j = r1.F; j <= r1.S; j++){
                if(ja[u][j].F != i){
                    f1[e] = i; t1[e++] = ja[u][j].F;
                }
            }
            for(int j = r2.F; j <= r2.S; j++){
                if(ja[v][j].F != i){
                    f1[e] = i; t1[e++] = ja[v][j].F;
                }
            }
        }

        c = new int[m]; ja = new pair[m][];
        for(int i = 0; i < e; i++){
            c[f1[i]]++; 
        }
        for(int i = 0; i < m; i++){
            ja[i] = new pair[c[i]];
            c[i] = 0;
        }
        for(int i = 0; i < e; i++){
            ja[f1[i]][c[f1[i]]++] = new pair(t1[i], t[t1[i]]);
        }

        visit = new boolean[m]; state = new int[m];
        long ans = -1;
        ArrayList<Integer> al = new ArrayList<>();
        ArrayList<Integer> al1 = new ArrayList<>();
        ArrayList<Integer> al2 = new ArrayList<>();
        for(int i = 0; i < m; i++){
            if(visit[i])continue;
            Arrays.fill(state, -1);
            al1.clear();
            long v1 = dfs(i, 0, al1);
            Arrays.fill(state, -1);
            al2.clear();
            long v2 = dfs(i, 1, al2);
            long x = Math.min(v1, v2);
            // System.out.println(v1 + " " + v2);
            if(x >= max){
                out.println(-1); return;
            }
            if(v1 < v2){
                al.addAll(al1);
            }else{
                al.addAll(al2);
            }
            ans = Math.max(ans, x);
        }
        out.println("Yes");
        out.println(ans + " " + al.size());
        for(int v : al){
            out.print(v + " ");
        }
    }
    boolean visit[];
    int state[];
    class pair{
        int F, S;
        pair(int a, int b){F = a; S = b;}
    }
    long dfs(int u, int s, ArrayList<Integer> al){
        visit[u] = true; state[u] = s;
        long ans = state[u] == 1 ? t[u] : 0;
        if(state[u] == 1){
            al.add(u + 1);
        }
        for(pair e : ja[u]){
            int v = e.F;
            if(state[v] != -1){
                if(state[v] != 1 - s) return max;
            }else{
                ans += dfs(v, 1 - s, al);
            }
            ans = Math.min(ans, max);
        }return ans;
    }
    public static class InputReader{
        BufferedReader br;
        StringTokenizer st;
        InputReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public long nextLong(){
            return Long.parseLong(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
        public String next(){
            while(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch(IOException e){}
            }
            return st.nextToken();
        }
    }
}
        