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;
struct gr {
  int v, u, c, t;
};
const int maxn = 3e5 + 20, INF = 1e9;
int n, m, comp[maxn], sz[2 * maxn], szrev[maxn];
bool mark[maxn];
vector<int> adj[maxn];
vector<int> edges[maxn], revedges[maxn], vec, tme;
gr e[maxn];
bool cmp(int x, int y) { return (e[x].c < e[y].c); }
inline int nt(int x) { return x ^ 1; }
inline void add_edge(int x, int y) {
  edges[x].push_back(y);
  revedges[y].push_back(x);
}
inline void add_cl(int x, int y) {
  add_edge(nt(x), y);
  add_edge(nt(y), x);
}
void dfs1(int v) {
  mark[v] = 1;
  for (auto u : edges[v]) {
    if (!mark[u]) {
      dfs1(u);
    }
  }
  vec.push_back(v);
}
void dfs2(int v, int c) {
  comp[v] = c;
  for (auto u : revedges[v]) {
    if (!comp[u]) {
      dfs2(u, c);
    }
  }
}
int nxt;
inline bool check(long long val) {
  vec.clear();
  for (int i = 0; i < nxt; ++i) {
    mark[i] = 0;
    comp[i] = 0;
    edges[i].resize(sz[i]);
    revedges[i].resize(szrev[i]);
  }
  for (int i = 0; i < m; ++i) {
    if (e[i].t > val) {
      add_cl(nt(2 * i), nt(2 * i));
    }
  }
  for (int i = 0; i < nxt; ++i) {
    if (!mark[i]) {
      dfs1(i);
    }
  }
  reverse(vec.begin(), vec.end());
  int cnt = 1;
  for (int i : vec) {
    if (!comp[i]) {
      dfs2(i, cnt);
      cnt++;
    }
  }
  for (int i = 0; i < nxt; i += 2) {
    if (comp[i] == comp[nt(i)]) {
      return 0;
    }
  }
  return 1;
}
inline void setup() {
  nxt = 2 * m;
  for (int i = 0; i < maxn; ++i) {
    edges[i].clear();
    revedges[i].clear();
  }
  for (int i = 0; i < n; ++i) {
    int prv = nxt, cnt = 0;
    if (adj[i].size()) {
      add_cl(nt(2 * adj[i][0]), prv);
      nxt += 2;
    }
    for (int j = 1; j < adj[i].size(); ++j) {
      int u = adj[i][j - 1], v = adj[i][j];
      int curr = nxt;
      nxt += 2;
      if (e[u].c == e[v].c) {
        cnt++;
        if (cnt > 1) {
          cout << "No" << endl;
          exit(0);
        }
        add_cl(2 * u, 2 * v);
      } else {
        cnt = 0;
      }
      add_cl(nt(2 * v), curr);
      add_cl(nt(prv), curr);
      add_cl(nt(prv), nt(2 * v));
      prv = curr;
    }
  }
  for (int i = 0; i < maxn; ++i) {
    sz[i] = edges[i].size();
    szrev[i] = revedges[i].size();
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int x, y, c, t;
    cin >> x >> y >> c >> t;
    x--;
    y--;
    e[i].v = x;
    e[i].u = y;
    e[i].c = c;
    e[i].t = t;
    adj[x].push_back(i);
    adj[y].push_back(i);
    tme.push_back(t);
  }
  for (int i = 0; i < n; ++i) {
    sort(adj[i].begin(), adj[i].end(), cmp);
  }
  tme.push_back(0);
  sort(tme.begin(), tme.end());
  tme.resize(unique(tme.begin(), tme.end()) - tme.begin());
  setup();
  long long l = -1, r = tme.size();
  while (l < r - 1) {
    long long m = (l + r) / 2;
    if (check(tme[m])) {
      r = m;
    } else {
      l = m;
    }
  }
  if (r == tme.size()) {
    cout << "No" << endl;
    return 0;
  }
  check(tme[r]);
  cout << "Yes" << endl;
  fill(mark, mark + maxn, 0);
  vector<int> ans;
  for (int i = 0; i < nxt; i += 2) {
    int v = comp[i], u = comp[nt(i)];
    mark[min(v, u)] = 0;
    mark[max(v, u)] = 1;
  }
  for (int i = 0; i < m; ++i) {
    if (mark[comp[2 * i]]) {
      ans.push_back(i + 1);
    }
  }
  cout << tme[r] << ' ' << ans.size() << endl;
  for (auto u : ans) {
    cout << u << ' ';
  }
  cout << endl;
}
