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 maxn = 2e5 + 1000;
int n, m;
vector<pair<int, int> > g[maxn];
vector<int> gg[maxn], topol;
int c[maxn], t[maxn], ans[maxn];
bool mark[maxn];
void dfs(int v) {
  mark[v] = 1;
  for (int i = 0; i < gg[v].size(); i++)
    if (!mark[gg[v][i]]) dfs(gg[v][i]);
  topol.push_back(v);
}
int NOT(int x) {
  if (x < m) return x + m;
  return x - m;
}
void add(int a, int b) {
  gg[NOT(a)].push_back(b);
  gg[NOT(b)].push_back(a);
}
bool ok(int time) {
  fill(ans, ans + maxn, -1);
  fill(mark, mark + maxn, 0);
  topol.clear();
  for (int i = 0; i < maxn; i++) gg[i].clear();
  for (int i = 1; i <= n; i++) {
    vector<int> vec;
    for (int j = 0; j < g[i].size(); j++) {
      if (time < t[g[i][j].second]) continue;
      vec.push_back(g[i][j].second);
    }
    for (int j = 0; j < vec.size(); j++)
      for (int jj = j + 1; jj < vec.size(); jj++)
        add(NOT(vec[j]), NOT(vec[jj]));
    map<int, int> mp;
    int bad = 0;
    for (int j = 0; j < g[i].size(); j++) {
      if (time < t[g[i][j].second]) continue;
      mp[c[g[i][j].second]]++;
      if (mp[c[g[i][j].second]] == 2) bad++;
      if (mp[c[g[i][j].second]] == 3 || bad == 2) return false;
    }
    if (bad == 0) continue;
    for (int j = 0; j < g[i].size(); j++)
      if (mp[c[g[i][j].second]] == 2) bad = c[g[i][j].second];
    int x = -1;
    for (int j = 0; j < g[i].size(); j++)
      if (c[g[i][j].second] == bad && x == -1)
        x = g[i][j].second;
      else if (c[g[i][j].second] == bad)
        add(x, g[i][j].second);
  }
  for (int i = 0; i < m * 2; i++)
    if (!mark[i]) dfs(i);
  for (int i = 0; i < 2 * m; i++) {
    int now = topol[i];
    if (now < m && ans[now] == -1) ans[now] = 1;
    if (now >= m && ans[now - m] == -1) ans[now - m] = 0;
  }
  for (int i = 0; i < m; i++)
    if (ans[i])
      if (time < t[i]) ans[i] = 0;
  for (int i = 1; i <= n; i++) {
    int numm = 0;
    map<int, int> mp;
    for (int j = 0; j < g[i].size(); j++) {
      if (ans[g[i][j].second] == 1) {
        numm++;
        continue;
      }
      mp[c[g[i][j].second]]++;
      if (mp[c[g[i][j].second]] == 2) return false;
    }
    if (numm >= 2) return false;
  }
  return true;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v >> c[i] >> t[i];
    g[u].push_back({v, i});
    g[v].push_back({u, i});
  }
  int l = 0, r = 100 + 1;
  if (!ok(r)) return cout << "No\n", 0;
  if (ok(l)) return cout << "Yes\n0 0\n", 0;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (ok(mid))
      r = mid;
    else
      l = mid;
  }
  cout << "Yes\n";
  ok(r);
  int kk = 0;
  for (int i = 0; i < m; i++) kk += (ans[i] == 1);
  cout << r << ' ' << kk << endl;
  for (int i = 0; i < m; i++)
    if (ans[i] == 1) cout << i + 1 << ' ';
  return 0;
}
