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>
using namespace std;
void nie() {
  cout << "No\n";
  exit(0);
}
map<int, set<pair<int, int> > > g[101010];
int u[101010];
int a[101010];
int b[101010];
int c[101010];
int d[101010];
int del[101010];
vector<int> v;
void stay(int);
void rm(int i) {
  if (u[i] == 1) nie();
  if (u[i] == 2) return;
  if (del[a[i]] || del[b[i]]) nie();
  del[a[i]] = 1;
  del[b[i]] = 1;
  u[i] = 2;
  v.push_back(i);
  g[a[i]][c[i]].erase({b[i], i});
  g[b[i]][c[i]].erase({a[i], i});
  for (auto& cc : g[a[i]]) {
    while (cc.second.size() > 0) {
      auto nx = cc.second.begin();
      stay((*nx).second);
    }
  }
  for (auto& cc : g[b[i]]) {
    while (cc.second.size() > 0) {
      auto nx = cc.second.begin();
      stay((*nx).second);
    }
  }
}
void stay(int i) {
  if (u[i] == 2) nie();
  if (u[i] == 1) return;
  u[i] = 1;
  g[a[i]][c[i]].erase({b[i], i});
  g[b[i]][c[i]].erase({a[i], i});
  while (g[a[i]][c[i]].size() > 0) {
    auto nx = g[a[i]][c[i]].begin();
    rm((*nx).second);
  }
  while (g[b[i]][c[i]].size() > 0) {
    auto nx = g[b[i]][c[i]].begin();
    rm((*nx).second);
  }
}
map<int, int> used[101010];
int dfs(int x, int p, int tc, vector<pair<int, int> >& r) {
  if (used[x][tc]) return 1;
  used[x][tc] = 1;
  for (auto nx : g[x][tc]) {
    if (nx.second != p) {
      r.push_back(nx);
      return dfs(nx.first, nx.second, tc, r);
    }
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    g[a[i]][c[i]].insert({b[i], i});
    g[b[i]][c[i]].insert({a[i], i});
    if (g[a[i]][c[i]].size() > 2) nie();
    if (g[b[i]][c[i]].size() > 2) nie();
  }
  for (int i = 1; i <= n; i++) {
    int f = -1;
    for (auto cc : g[i]) {
      if (cc.second.size() > 1) {
        if (f > -1) nie();
        f = cc.first;
      }
    }
    if (f > -1) {
      for (auto cc : g[i]) {
        if (cc.first != f) {
          for (auto nx : cc.second) {
            stay(nx.second);
          }
        }
      }
    }
  }
  vector<pair<int, vector<pair<int, int> > > > lol;
  for (int i = 1; i <= n; i++) {
    for (auto col : g[i]) {
      if (col.second.size() == 1) {
        vector<pair<int, int> > aa;
        int asd = dfs(i, 0, col.first, aa);
        if (aa.size() > 0) {
          lol.push_back({asd, aa});
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (auto col : g[i]) {
      if (col.second.size() == 2) {
        vector<pair<int, int> > aa;
        int asd = dfs(i, 0, col.first, aa);
        if (aa.size() > 0) {
          lol.push_back({asd, aa});
        }
      }
    }
  }
  for (auto& t : lol) {
    if (t.first == 1 && t.second.size() % 2 == 1) {
      nie();
    }
    if (t.second.size() > 1) {
      int mo = 0;
      int me = 0;
      for (int i = 0; i < (int)t.second.size(); i++) {
        if (i % 2 == 0) {
          me = max(me, d[t.second[i].second]);
        } else {
          mo = max(mo, d[t.second[i].second]);
        }
      }
      if (mo > me) {
        for (int i = 0; i < (int)t.second.size(); i += 2) {
          v.push_back(t.second[i].second);
        }
      } else {
        for (int i = 1; i < (int)t.second.size(); i += 2) {
          v.push_back(t.second[i].second);
        }
      }
    }
  }
  int vm = 0;
  for (auto k : v) {
    vm = max(vm, d[k]);
  }
  cout << "Yes" << endl;
  cout << vm << " " << v.size() << endl;
  for (int k : v) {
    cout << k << " ";
  }
}
