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 mox = 5e4 + 9;
vector<int> v[mox];
vector<pair<pair<int, int>, pair<int, int> > > ya;
vector<int> vr[100 * mox], vb[100 * mox];
map<int, int> ra;
int vis[mox];
bool visit[mox], visit2[mox];
stack<int> s;
int mol[mox];
int mo;
void dfs(int x) {
  visit[x] = 1;
  for (int i : vr[x]) {
    if (visit[i] == 0) {
      dfs(i);
    }
  }
  s.push(x);
}
void dfs2(int x) {
  visit2[x] = 1;
  mol[x] = mo;
  for (int i : vb[x]) {
    if (visit2[i] == 0) {
      dfs2(i);
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  int h = 1;
  for (int i = 0; i < m; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (ra[c] == 0) {
      ra[c] = h;
      h++;
    }
    v[a].push_back(i);
    v[b].push_back(i);
    ya.push_back({{a, b}, {ra[c], d}});
  }
  int low = -1;
  int hi = 1e9 + 1;
  while (low < hi - 1) {
    int mid = (low + hi) / 2;
    for (int i = 0; i < m; i++) {
      if (ya[i].second.second > mid) {
        vr[(2 * i)].push_back((2 * i) + 1);
        vb[(2 * i) + 1].push_back((2 * i));
      }
    }
    int x = 2 * m;
    for (int i = 1; i <= n; i++) {
      bool ok = 0;
      for (int j : v[i]) {
        for (int w = 0; w < 20; w++) {
          if ((j & (1 << w))) {
            vr[x + (4 * w)].push_back((2 * j) + 1);
            vb[(2 * j) + 1].push_back(x + (4 * w));
            vr[(2 * j)].push_back(x + (4 * w) + 1);
            vb[x + (4 * w) + 1].push_back((2 * j));
          } else {
            vr[x + (4 * w) + 1].push_back((2 * j) + 1);
            vb[(2 * j) + 1].push_back(x + (4 * w) + 1);
            vr[(2 * j)].push_back(x + (4 * w));
            vb[x + (4 * w)].push_back((2 * j));
          }
          if ((j & (1 << w))) {
            vb[x + (4 * w) + 2].push_back((2 * j));
            vr[(2 * j)].push_back(x + (4 * w) + 2);
            vb[(2 * j) + 1].push_back(x + (4 * w) + 3);
            vr[x + (4 * w) + 3].push_back((2 * j) + 1);
          } else {
            vb[x + (4 * w) + 3].push_back((2 * j));
            vr[(2 * j)].push_back(x + (4 * w) + 3);
            vb[(2 * j) + 1].push_back(x + (4 * w) + 2);
            vr[x + (4 * w) + 2].push_back((2 * j) + 1);
          }
        }
        x += 80;
        if (vis[ya[j].second.first] != 0) {
          if (ok == 1) {
            cout << "No";
            exit(0);
          }
          int y = vis[ya[j].second.first] - 1;
          vr[(2 * j) + 1].push_back(2 * y);
          vr[(2 * y) + 1].push_back((2 * j));
          vr[(2 * j)].push_back((2 * y) + 1);
          vr[(2 * y)].push_back((2 * j) + 1);
          vb[(2 * j) + 1].push_back(2 * y);
          vb[(2 * y) + 1].push_back((2 * j));
          vb[(2 * j)].push_back((2 * y) + 1);
          vb[(2 * y)].push_back((2 * j) + 1);
          ok = 1;
        }
        vis[ya[j].second.first] = j + 1;
      }
      for (int j : v[i]) vis[ya[j].second.first] = 0;
    }
    for (int i = 0; i < x; i++) {
      if (visit[i] == 0) {
        dfs(i);
      }
    }
    while (s.empty() == 0) {
      int v = s.top();
      s.pop();
      if (visit2[v] == 0) {
        dfs2(v);
        mo++;
      }
    }
    bool ok = 0;
    for (int i = 0; i < 2 * m; i += 2) {
      if (mol[i] == mol[i + 1]) {
        ok = 1;
        break;
      }
    }
    if (ok == 0) {
      hi = mid;
    } else {
      low = mid;
    }
    memset(visit, 0, sizeof(visit));
    memset(visit2, 0, sizeof(visit2));
    memset(mol, 0, sizeof(mol));
    mo = 0;
    for (int i = 0; i < x; i++) {
      vr[i].clear();
      vb[i].clear();
    }
  }
  if (hi == 1e9 + 1) {
    cout << "No";
    exit(0);
  }
  int mid = hi;
  for (int i = 0; i < m; i++) {
    if (ya[i].second.second > mid) {
      vr[(2 * i)].push_back((2 * i) + 1);
      vb[(2 * i) + 1].push_back((2 * i));
    }
  }
  int x = 2 * m;
  for (int i = 1; i <= n; i++) {
    bool ok = 0;
    for (int j : v[i]) {
      for (int w = 0; w < 20; w++) {
        if ((j & (1 << w))) {
          vr[x + (4 * w)].push_back((2 * j) + 1);
          vb[(2 * j) + 1].push_back(x + (4 * w));
          vr[(2 * j)].push_back(x + (4 * w) + 1);
          vb[x + (4 * w) + 1].push_back((2 * j));
        } else {
          vr[x + (4 * w) + 1].push_back((2 * j) + 1);
          vb[(2 * j) + 1].push_back(x + (4 * w) + 1);
          vr[(2 * j)].push_back(x + (4 * w));
          vb[x + (4 * w)].push_back((2 * j));
        }
        if ((j & (1 << w))) {
          vb[x + (4 * w) + 2].push_back((2 * j));
          vr[(2 * j)].push_back(x + (4 * w) + 2);
          vb[(2 * j) + 1].push_back(x + (4 * w) + 3);
          vr[x + (4 * w) + 3].push_back((2 * j) + 1);
        } else {
          vb[x + (4 * w) + 3].push_back((2 * j));
          vr[(2 * j)].push_back(x + (4 * w) + 3);
          vb[(2 * j) + 1].push_back(x + (4 * w) + 2);
          vr[x + (4 * w) + 2].push_back((2 * j) + 1);
        }
      }
      x += 80;
      if (vis[ya[j].second.first] != 0) {
        if (ok == 1) {
          cout << "No";
          exit(0);
        }
        int y = vis[ya[j].second.first] - 1;
        vr[(2 * j) + 1].push_back(2 * y);
        vr[(2 * y) + 1].push_back((2 * j));
        vr[(2 * j)].push_back((2 * y) + 1);
        vr[(2 * y)].push_back((2 * j) + 1);
        vb[(2 * j) + 1].push_back(2 * y);
        vb[(2 * y) + 1].push_back((2 * j));
        vb[(2 * j)].push_back((2 * y) + 1);
        vb[(2 * y)].push_back((2 * j) + 1);
        ok = 1;
      }
      vis[ya[j].second.first] = j + 1;
    }
    for (int j : v[i]) vis[ya[j].second.first] = 0;
  }
  for (int i = 0; i < x; i++) {
    if (visit[i] == 0) {
      dfs(i);
    }
  }
  while (s.empty() == 0) {
    int v = s.top();
    s.pop();
    if (visit2[v] == 0) {
      dfs2(v);
      mo++;
    }
  }
  int ans = 0;
  for (int i = 0; i < 2 * m; i += 2) {
    if (mol[i] > mol[i + 1]) {
      ans += 1;
    }
  }
  cout << "Yes" << '\n' << hi << " " << ans << '\n';
  for (int i = 0; i < 2 * m; i += 2) {
    if (mol[i] > mol[i + 1]) {
      cout << (i / 2) + 1 << " ";
    }
  }
}
