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>
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
using namespace std;
long long poww(long long a, long long b, long long md) {
  return (!b ? 1
             : (b & 1 ? a * poww(a * a % md, b / 2, md) % md
                      : poww(a * a % md, b / 2, md) % md));
}
const int maxn = 3000 * 100 + 5;
const long long inf = 9223372036854775807;
const long long mod = 1e9 + 7;
long long n, m, col[maxn], mark[maxn], c, val[maxn], vis[maxn];
pair<pair<long long, long long>, pair<long long, long long> > e[maxn];
vector<long long> in[maxn], out[maxn], adj[maxn], Cin[maxn], Cout[maxn], top,
    ans;
inline void add(long long a, long long b) {
  out[a].push_back(b);
  in[b].push_back(a);
}
inline void addC(long long a, long long b) {
  Cout[a].push_back(b);
  Cin[b].push_back(a);
}
void sfd(long long v) {
  mark[v] = 1;
  col[v] = c;
  for (auto u : in[v]) {
    if (!mark[u]) sfd(u);
  }
  if ((v & 1) && vis[e[v / 2].first.first] < 2) {
    vis[e[v / 2].first.first] += 1;
    for (auto u : adj[e[v / 2].first.first]) {
      if (!mark[2 * u] && u != v / 2) sfd(2 * u);
    }
  }
  if ((v & 1) && vis[e[v / 2].first.second] < 2) {
    vis[e[v / 2].first.second] += 1;
    for (auto u : adj[e[v / 2].first.second]) {
      if (!mark[2 * u] && u != v / 2) sfd(2 * u);
    }
  }
}
void dfs(long long v) {
  mark[v] = 1;
  for (auto u : out[v]) {
    if (!mark[u]) dfs(u);
  }
  if (v % 2 == 0 && vis[e[v / 2].first.first] < 2) {
    vis[e[v / 2].first.first] += 1;
    for (auto u : adj[e[v / 2].first.first]) {
      if (!mark[2 * u + 1] && u != v / 2) {
        dfs(2 * u + 1);
      }
    }
  }
  if (v % 2 == 0 && vis[e[v / 2].first.second] < 2) {
    vis[e[v / 2].first.second] += 1;
    for (auto u : adj[e[v / 2].first.second]) {
      if (!mark[2 * u + 1] && u != v / 2) {
        dfs(2 * u + 1);
      }
    }
  }
  top.push_back(v);
}
bool check(long long x) {
  for (long long i = 0; i < maxn; i++) {
    col[i] = 0;
    mark[i] = 0;
    val[i] = 0;
    if ((long long)(Cin[i]).size() == 0)
      in[i].clear();
    else {
      while ((long long)(in[i]).size() != (long long)(Cin[i]).size())
        in[i].pop_back();
    }
    if ((long long)(Cout[i]).size() == 0)
      out[i].clear();
    else {
      while ((long long)(out[i]).size() != (long long)(Cout[i]).size())
        out[i].pop_back();
    }
  }
  top.clear();
  c = 0;
  fill(vis, vis + maxn, 0);
  for (long long i = 1; i <= m; i++) {
    if (e[i].second.second > x) {
      add(2 * i, 2 * i + 1);
    }
  }
  for (long long i = 2; i <= 2 * m + 1; i++) {
    if (!mark[i]) {
      dfs(i);
    }
  }
  reverse((top).begin(), (top).end());
  fill(mark, mark + maxn, 0);
  fill(vis, vis + maxn, 0);
  for (auto i : top) {
    if (!mark[i]) {
      c++;
      sfd(i);
    }
  }
  for (long long i = 1; i <= m; i++) {
    if (col[2 * i] == col[2 * i + 1]) {
      return false;
    }
    val[i] = (col[2 * i] > col[2 * i + 1]);
  }
  return true;
}
void print(long long x) {
  if (x % 2 == 0) {
    cout << x / 2;
  } else
    cout << "~" << x / 2;
}
map<long long, long long> cnt[maxn], last[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    cin >> e[i].first.first >> e[i].first.second >> e[i].second.first >>
        e[i].second.second;
    adj[e[i].first.first].push_back(i);
    adj[e[i].first.second].push_back(i);
    if (last[e[i].first.second].count(e[i].second.first)) {
      addC(2 * i + 1, 2 * last[e[i].first.second][e[i].second.first]);
      addC(2 * last[e[i].first.second][e[i].second.first] + 1, 2 * i);
    }
    if (last[e[i].first.first].count(e[i].second.first)) {
      addC(2 * i + 1, 2 * last[e[i].first.first][e[i].second.first]);
      addC(2 * last[e[i].first.first][e[i].second.first] + 1, 2 * i);
    }
    cnt[e[i].first.first][e[i].second.first]++;
    last[e[i].first.first][e[i].second.first] = i;
    cnt[e[i].first.second][e[i].second.first]++;
    last[e[i].first.second][e[i].second.first] = i;
  }
  for (long long i = 1; i <= n; i++) {
    for (auto u : adj[i]) {
      if (cnt[i][e[u].second.first] > 2) {
        cout << "No";
        return 0;
      }
    }
  }
  for (long long i = 2; i < maxn; i++) {
    for (auto u : Cout[i]) {
      out[i].push_back(u);
    }
    for (auto u : Cin[i]) {
      in[i].push_back(u);
    }
  }
  long long l = -1, r = mod * 100 + 10, mid;
  while (r - l > 1) {
    mid = (l + r) >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  if (l == mod * 100 + 9) {
    cout << "No";
    return 0;
  }
  cout << "Yes" << endl;
  check(r);
  for (long long i = 1; i <= m; i++) {
    if (val[i]) ans.push_back(i);
  }
  cout << r << " " << ans.size() << endl;
  for (auto u : ans) cout << u << " ";
}
