#include <bits/stdc++.h>
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
using namespace ::std;
const int maxn = 5e4 + 500;
const int nott = (1 << 19);
vector<int> out[2 * nott];
vector<int> in[2 * nott];
vector<int> topol;
bitset<2 * nott> chosss;
bitset<2 * nott> vis;
int moa[2 * nott];
void sfd(int a, int b) {
  if (vis[a]) return;
  moa[a] = b;
  vis[a] = 1;
  for (auto v : in[a]) {
    sfd(v, b);
  }
}
void dfs(int a) {
  if (vis[a]) return;
  vis[a] = 1;
  for (auto v : out[a]) {
    dfs(v);
  }
  topol.push_back(a);
}
bool is_ok(int n) {
  topol.clear();
  vis = 0;
  topol.reserve(2 * n);
  chosss = 0;
  for (int i = 0; i < n; i++) {
    dfs(i);
    dfs(i ^ nott);
  }
  vis = 0;
  reverse(topol.begin(), topol.end());
  int cnt = 0;
  for (auto v : topol) {
    sfd(v, cnt);
    cnt++;
  }
  for (int i = 0; i < n; i++) {
    if (moa[i] == moa[i ^ nott]) {
      return 0;
    }
    if (moa[i] > moa[i ^ nott]) {
      chosss[i] = 1;
    }
  }
  return 1;
}
bool chose[maxn];
vector<pair<int, int> > yal;
void add_yal(int a, int b) {
  out[a].push_back(b);
  in[b].push_back(a);
  yal.push_back(make_pair(a, b));
}
void pop_yal() {
  out[yal.back().first].pop_back();
  in[yal.back().second].pop_back();
  yal.pop_back();
}
void add_shart(int a, int b) {
  add_yal(a ^ nott, b);
  add_yal(b ^ nott, a);
}
void pop_shart() {
  pop_yal();
  pop_yal();
}
vector<int> ger[maxn];
int s[maxn];
int t[maxn];
int w[maxn];
int c[maxn];
bool check(int W, int n, int m) {
  int cnt = 0;
  for (int i = 0; i < m; i++) {
    if (w[i] > W) {
      cnt++;
      add_shart((i * 5) ^ nott, (i * 5) ^ nott);
    }
  }
  bool ans = is_ok(m * 5);
  for (int i = 0; i < m; i++) {
    chose[i] = chosss[i * 5];
  }
  while (cnt--) {
    pop_shart();
  }
  return ans;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> comp;
  comp.push_back(0);
  for (int i = 0; i < m; i++) {
    cin >> s[i] >> t[i] >> c[i] >> w[i];
    ger[s[i]].push_back(i);
    ger[t[i]].push_back(i);
    comp.push_back(w[i]);
  }
  {
    sort(comp.begin(), comp.end());
    auto it = unique(comp.begin(), comp.end());
    comp.resize(it - comp.begin());
  }
  for (int i = 1; i <= n; i++) {
    int last = -1;
    for (auto v : ger[i]) {
      int u = 5 * v;
      int komu = u + 1;
      if (s[v] == i) {
        komu++;
      }
      add_shart(u ^ nott, komu);
      if (last != -1) {
        add_shart(last ^ nott, komu);
        add_shart(last ^ nott, u ^ nott);
      }
      last = komu;
    }
  }
  for (int i = 1; i <= n; i++) {
    map<int, vector<int> > ml;
    for (auto v : ger[i]) {
      ml[c[v]].push_back(v);
    }
    for (auto& VEC : ml) {
      int last = -1;
      for (auto v : VEC.second) {
        int u = 5 * v;
        int komu = u + 3;
        if (s[v] == i) {
          komu++;
        }
        add_shart(u, (komu) ^ nott);
        if (last != -1) {
          add_shart((last), (komu) ^ nott);
          add_shart((last), u);
        }
        last = komu;
      }
    }
  }
  if (!check(comp.back(), n, m)) {
    cout << "No";
    return 0;
  }
  int b = -1;
  int e = comp.size() - 1;
  cout << "Yes\n";
  while (e - b > 1) {
    int mid = (e + b) / 2;
    if (check(comp[mid], n, m)) {
      e = mid;
    } else {
      b = mid;
    }
  }
  check(comp[e], n, m);
  vector<int> ans;
  for (int i = 0; i < m; i++) {
    if (chose[i]) {
      ans.push_back(i + 1);
    }
  }
  cout << comp[e] << ' ' << ans.size() << endl;
  for (auto v : ans) {
    cout << v << ' ';
  }
}
