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 long long MAXN = 4e5 + 10;
const long long INF = 1e9 + 10;
vector<long long> in[MAXN];
vector<long long> out[MAXN];
vector<pair<long long, long long> > vertex[MAXN];
vector<long long> ts;
long long w[MAXN];
long long co[MAXN];
long long va[MAXN];
bool check[MAXN];
long long n, m, t;
void add_edge(long long x, long long y) {
  out[x].push_back(y);
  in[y].push_back(x);
}
void add_clause(long long x, long long y) {
  add_edge(x ^ 1, y);
  add_edge(y ^ 1, x);
}
void topological_sort(long long v) {
  check[v] = true;
  for (long long i = 0; i < out[v].size(); i++) {
    if (!check[out[v][i]]) {
      topological_sort(out[v][i]);
    }
  }
  ts.push_back(v);
}
void scc_dfs(long long v, long long k) {
  co[v] = k;
  check[v] = true;
  for (long long i = 0; i < in[v].size(); i++) {
    if (!check[in[v][i]]) {
      scc_dfs(in[v][i], k);
    }
  }
}
bool two_sat() {
  ts.clear();
  fill(check, check + MAXN, false);
  for (long long i = 1; i < 2 * t; i++) {
    if (!check[i]) {
      topological_sort(i);
    }
  }
  fill(check, check + MAXN, false);
  long long k = 1;
  for (long long i = 2 * t - 2; i >= 0; i--) {
    if (!check[ts[i]]) {
      scc_dfs(ts[i], k++);
    }
  }
  fill(va, va + MAXN, -1);
  for (long long i = 0; i <= 2 * t - 2; i++) {
    long long v = ts[i];
    if (co[v] == co[v ^ 1]) {
      return false;
    }
    if (va[co[v]] == -1) {
      va[co[v]] = 1;
      va[co[v ^ 1]] = 0;
    }
  }
  return true;
}
bool bs_check(long long x) {
  for (long long i = 1; i < MAXN; i++) {
    out[i].clear();
    in[i].clear();
  }
  for (long long i = 1; i <= m; i++) {
    if (w[i] > x) {
      add_clause(2 * i + 1, 2 * i + 1);
    }
  }
  t = m + 1;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j < vertex[i].size(); j++) {
      add_clause(2 * vertex[i][j].second + 1, 2 * t);
      if (j >= 1) {
        add_clause(2 * (t - 1) + 1, 2 * t);
        add_clause(2 * vertex[i][j].second + 1, 2 * (t - 1) + 1);
      }
      t++;
      if (j >= 1 && vertex[i][j].first == vertex[i][j - 1].first) {
        add_clause(2 * vertex[i][j].second, 2 * vertex[i][j - 1].second);
      }
    }
  }
  return two_sat();
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    long long v, u, c;
    cin >> v >> u >> c >> w[i];
    vertex[v].push_back(make_pair(c, i));
    vertex[u].push_back(make_pair(c, i));
  }
  for (long long i = 1; i <= n; i++) {
    sort(vertex[i].begin(), vertex[i].end());
    for (long long j = 0; j < vertex[i].size(); j++) {
      if (j >= 2 && vertex[i][j].first == vertex[i][j - 2].first) {
        cout << "No";
        return 0;
      }
    }
  }
  long long L = -1, R = INF;
  while (R - L > 1) {
    long long mid = (L + R) / 2;
    if (bs_check(mid)) {
      R = mid;
    } else {
      L = mid;
    }
  }
  if (bs_check(R)) {
    cout << "Yes" << endl;
    long long total = 0;
    for (long long i = 1; i <= m; i++) {
      if (va[co[2 * i]] == 1) {
        total++;
      }
    }
    cout << R << " " << total << endl;
    for (long long i = 1; i <= m; i++) {
      if (va[co[2 * i]] == 1) {
        cout << i << " ";
      }
    }
  } else {
    cout << "No";
  }
}
