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 = 1e6 + 7, M = 5e6 + 7;
map<pair<int, int>, int> g;
vector<int> s[N], o[M], re;
int a[N], b[N], c[N], d[N], dfn[N], low[N], head[N], to[M], nxt[M], cnt, sta[N],
    top, tot, bl[N], tk, tmp[N], m, num;
bool in[N];
inline void link(int a, int b) {
  to[++cnt] = b, nxt[cnt] = head[a], head[a] = cnt;
}
void Tarjan(int x) {
  dfn[x] = low[x] = ++tot;
  sta[++top] = x;
  in[x] = 1;
  for (int i = head[x]; i; i = nxt[i]) {
    int y = to[i];
    if (!dfn[y])
      Tarjan(y), low[x] = min(low[x], low[y]);
    else if (in[y])
      low[x] = min(low[x], dfn[y]);
  }
  if (low[x] == dfn[x]) {
    ++num;
    while (top) {
      int p = sta[top--];
      in[p] = 0, bl[p] = num;
      if (p == x) break;
    }
  }
}
bool check(int x) {
  for (int i = 1; i <= 2 * m; ++i) head[i] = tmp[i];
  cnt = tk;
  for (int i = 1; i <= m; ++i)
    if (d[i] > x) link(i, i + m);
  num = 0;
  tot = 0;
  memset(dfn, 0, sizeof dfn);
  for (int i = 1; i <= 10 * m; ++i)
    if (!dfn[i]) Tarjan(i);
  for (int i = 1; i <= m; ++i)
    if (bl[i] == bl[i + m]) return 0;
  return 1;
}
int main() {
  int n, tot = 0;
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d%d%d", &a[i], &b[i], &c[i], &d[i]);
    if (!g[make_pair(a[i], c[i])]) g[make_pair(a[i], c[i])] = ++tot;
    if (!g[make_pair(b[i], c[i])]) g[make_pair(b[i], c[i])] = ++tot;
    s[a[i]].push_back(i), s[b[i]].push_back(i);
    o[g[make_pair(a[i], c[i])]].push_back(i),
        o[g[make_pair(b[i], c[i])]].push_back(i);
  }
  int tp = 2 * m;
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j < s[i].size(); ++j) {
      ++tp;
      link(tp + 2 * m, s[i][j] + m);
      link(s[i][j], tp);
      if (j)
        link(tp - 1, tp), link(s[i][j], tp - 1 + 2 * m),
            link(tp + 2 * m, tp - 1 + 2 * m), link(tp - 1, s[i][j] + m);
    }
  tp = 6 * m;
  for (int i = 1; i <= tot; ++i)
    for (int j = 0; j < o[i].size(); ++j) {
      ++tp;
      link(tp + 2 * m, o[i][j]);
      link(o[i][j] + m, tp);
      if (j)
        link(tp - 1, tp), link(tp + 2 * m, tp - 1 + 2 * m),
            link(o[i][j] + m, tp - 1 + 2 * m), link(tp - 1, o[i][j]);
    }
  for (int i = 1; i <= 2 * m; ++i) tmp[i] = head[i];
  tk = cnt;
  int l = 0, r = 1e9 + 7;
  int ans = -1;
  while (l <= r) {
    int mid = l + r >> 1;
    if (check(mid))
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  if (ans == -1) return puts("No"), 0;
  puts("Yes");
  check(ans);
  for (int i = 1; i <= m; ++i)
    if (bl[i + m] > bl[i]) re.push_back(i);
  cout << ans << ' ' << re.size() << endl;
  for (int i = 0; i < re.size(); ++i) cout << re[i] << ' ';
  puts("");
  return 0;
}
