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;
const int N = 150000 + 77;
struct SAT {
  int n, gp[N << 1], nt;
  bool M[N << 1], res[N << 1];
  vector<pair<bool, int> > a[N << 1];
  vector<int> ts;
  SAT(int n1) {
    n = n1;
    Clear();
  }
  void Clear() {
    ts.clear();
    nt = 0;
    for (int i = 0; i < (n << 1); i++) {
      M[i] = false;
      a[i].clear();
      gp[i] = 0;
      res[i] = false;
    }
  }
  void Add(int x, int y) {
    a[x ^ 1].push_back(make_pair(1, y));
    a[y].push_back(make_pair(0, x ^ 1));
    a[y ^ 1].push_back(make_pair(1, x));
    a[x].push_back(make_pair(0, y ^ 1));
  }
  bool Check() {
    for (int i = 2; i <= (n << 1) + 1; i++) M[i] = false;
    ts.clear();
    for (int i = 2; i <= (n << 1) + 1; i++)
      if (!M[i]) dfs(i);
    for (int i = 2; i <= (n << 1) + 1; i++) M[i] = false;
    while (ts.size()) {
      if (M[ts.back()]) {
        ts.pop_back();
        continue;
      }
      ++nt;
      findscc(ts.back());
      ts.pop_back();
    }
    for (int i = 2; i <= (n << 1) + 1; i++)
      if (gp[i] == gp[i ^ 1]) return false;
    return true;
  }
  void dfs(int v) {
    M[v] = true;
    for (auto x : a[v]) {
      int u = x.second;
      bool t = x.first;
      if ((!t) || (M[u])) continue;
      dfs(u);
    }
    ts.push_back(v);
  }
  void findscc(int v) {
    gp[v] = nt;
    M[v] = true;
    for (auto x : a[v]) {
      int u = x.second;
      bool t = x.first;
      if (t || M[u]) continue;
      findscc(u);
    }
  }
  vector<bool> GetAnswer() {
    for (int i = (n << 1) + 1; i > 1; --i) M[i] = false;
    ts.clear();
    for (int i = (n << 1) + 1; i > 1; --i)
      if (!M[i]) dfs(i);
    while (!ts.empty()) {
      int v = ts.back();
      res[v] = !res[v ^ 1];
      ts.pop_back();
    }
    vector<bool> r;
    for (int i = 2; i <= (n << 1); i += 2) r.push_back(!res[i]);
    return r;
  }
};
int n, m, tim;
int Qv[N], Qu[N], Qt[N], Qc[N];
vector<int> Vt, a[N];
bool CMP(int x, int y) { return Qc[x] < Qc[y]; }
inline bool Check(int t, bool pr = 0) {
  tim = m + 1;
  SAT S = SAT(m * 3 + 7);
  for (int i = 1; i <= m; ++i)
    if (Qt[i] > t) S.Add((i << 1) ^ 1, (i << 1) ^ 1);
  vector<int> R;
  for (int i = 1; i <= n; ++i) {
    int sz = a[i].size();
    for (int j = 0; j < sz; ++j) {
      S.Add((a[i][j] << 1) ^ 1, (tim + j) << 1);
      if (j > 0)
        S.Add(((tim + j - 1) << 1) ^ 1, (tim + j) << 1),
            S.Add(((tim + j - 1) << 1) ^ 1, (a[i][j] << 1) ^ 1);
    }
    tim += sz;
    if (tim > m * 3 + 7) cout << "WTF";
    vector<int> R;
    for (int x : a[i]) {
      if (!R.empty() && Qc[R.back()] != Qc[x]) {
        if (R.size() > 2) return 0;
        if (R.size() == 2) S.Add(R[0] << 1, R[1] << 1);
        R.clear();
      }
      R.push_back(x);
    }
    if (R.size() > 2) return 0;
    if (R.size() == 2) S.Add(R[0] << 1, R[1] << 1);
    R.clear();
  }
  if (pr) {
    vector<int> A;
    vector<bool> T = S.GetAnswer();
    for (int i = 1; i <= m; ++i)
      if (T[i - 1]) A.push_back(i);
    printf("%d %d\n", t, int(A.size()));
    for (int x : A) printf("%d ", x);
  }
  return S.Check();
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d %d %d %d", Qv + i, Qu + i, Qc + i, Qt + i);
    Vt.push_back(Qt[i]);
    a[Qv[i]].push_back(i);
    a[Qu[i]].push_back(i);
  }
  Vt.push_back(0);
  sort(Vt.begin(), Vt.end());
  Vt.resize(unique(Vt.begin(), Vt.end()) - Vt.begin());
  for (int i = 1; i <= n; ++i) sort(a[i].begin(), a[i].end(), CMP);
  int le = -1, ri = Vt.size();
  while (ri - le > 1) {
    int mid = ((le + ri) >> 1);
    if (Check(Vt[mid]))
      ri = mid;
    else
      le = mid;
  }
  if (ri == Vt.size()) return !printf("No\n");
  printf("Yes\n");
  Check(Vt[ri], 1);
  return 0;
}
