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;
template <class T>
void _R(T &x) {
  cin >> x;
}
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <class T, class... U>
void R(T &head, U &...tail) {
  _R(head);
  R(tail...);
}
template <class T>
void _W(const T &x) {
  cout << x;
}
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template <class T, class U>
void _W(const pair<T, U> &x) {
  _W(x.F);
  putchar(' ');
  _W(x.S);
}
template <class T>
void _W(const vector<T> &x) {
  for (auto i = x.begin(); i != x.end(); _W(*i++))
    if (i != x.cbegin()) putchar(' ');
}
void W() {}
template <class T, class... U>
void W(const T &head, const U &...tail) {
  _W(head);
  putchar(sizeof...(tail) ? ' ' : '\n');
  W(tail...);
}
const int MAXN = 2e6 + 10, MAXM = 4e6 + 10;
const int INF = INT_MAX, SINF = 0x3f3f3f3f;
const long long llINF = LLONG_MAX;
const int MOD = 1e9 + 7, mod = 998244353;
const int inv2 = 5e8 + 4;
const int Lim = 1 << 20;
vector<int> g[MAXN];
int tot, dfn[MAXN], low[MAXN];
int cir[MAXN], cirnum;
stack<int> sta;
void tarjan(int u) {
  dfn[u] = low[u] = ++tot;
  sta.push(u);
  for (auto v : g[u]) {
    if (!dfn[v]) {
      tarjan(v);
      low[u] = min(low[u], low[v]);
    } else if (!cir[v])
      low[u] = min(low[u], dfn[v]);
  }
  if (dfn[u] == low[u]) {
    cir[u] = ++cirnum;
    while (sta.top() != u) {
      cir[sta.top()] = cirnum;
      sta.pop();
    }
    sta.pop();
  }
}
struct Edge {
  int u, v, c, t;
} e[MAXN];
vector<int> ans;
int cnt, n, m;
void work1(vector<int> &v) {
  int S = 0, T = 0;
  for (auto x : v) {
    int y = x + m, s = ++cnt, t = ++cnt;
    g[x].push_back(s);
    g[t].push_back(y);
    if (S && T)
      g[S].push_back(s), g[t].push_back(T), g[S].push_back(y),
          g[x].push_back(T);
    S = s, T = t;
  }
}
void work2(vector<int> &v) {
  int S = 0, T = 0;
  for (auto x : v) {
    int y = x + m, s = ++cnt, t = ++cnt;
    g[s].push_back(x);
    g[y].push_back(t);
    if (S && T)
      g[s].push_back(S), g[T].push_back(t), g[y].push_back(S),
          g[T].push_back(x);
    S = s, T = t;
  }
}
bool check(int o) {
  for (int i = 1; i <= m; i++)
    if (e[i].t > o) g[i].push_back(i + m);
  memset(dfn, 0, (cnt + 5) * sizeof(int));
  memset(low, 0, (cnt + 5) * sizeof(int));
  memset(cir, 0, (cnt + 5) * sizeof(int));
  cirnum = tot = 0;
  for (int i = 1; i <= cnt; i++)
    if (!dfn[i]) tarjan(i);
  for (int i = 1; i <= m; i++)
    if (e[i].t > o) g[i].pop_back();
  for (int i = 1; i <= m; i++)
    if (cir[i] == cir[i + m]) return false;
  ans.resize(0);
  for (int i = 1; i <= m; i++)
    if (cir[i] < cir[i + m]) ans.push_back(i);
  return true;
}
vector<int> v[MAXN];
void solve() {
  R(n, m);
  cnt = m * 2;
  for (int i = 1; i <= m; i++) {
    R(e[i].u, e[i].v, e[i].c, e[i].t);
    v[e[i].u].push_back(i);
    v[e[i].v].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    sort((v[i]).begin(), (v[i]).end(),
         [&](int a, int b) { return e[a].c < e[b].c; });
    work1(v[i]);
    vector<int> tmp;
    for (int j = 0; j < ((int)v[i].size()); j++) {
      if (j && e[v[i][j]].c != e[v[i][j - 1]].c) {
        work2(tmp);
        tmp.resize(0);
      }
      tmp.push_back(v[i][j]);
    }
    work2(tmp);
  }
  int l = 0, r = 1e9, res = 1e9;
  if (!check(r)) return W("No");
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid))
      res = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  check(res);
  W("Yes");
  W(res, ((int)ans.size()));
  W(ans);
}
int main() {
  int t = 1;
  while (t--) solve();
  return 0;
}
