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 inf = 1e18;
const long long mod = 998244353;
const long long maxn = 5e4 + 10, maxval = 1e9 + 10, mlg = (1 << 18) + 10;
struct edge {
  long long u, v, c, t;
} ed[maxn * 6];
long long n, m, cnt;
long long ans[maxn * 6], comp[maxn * 6], mark1[6 * maxn], mark2[6 * maxn];
vector<long long> ts, nei[maxn * 6][2], adj[maxn * 6];
map<long long, long long> mp;
long long N(long long x) {
  if (x <= m) {
    return x + m;
  } else if (x <= 2 * m) {
    return x - m;
  } else if (x <= 4 * m) {
    return x + 2 * m;
  } else {
    return x - 2 * m;
  }
}
void add_con(long long x, long long y) {
  long long nagh_x = N(x);
  long long nagh_y = N(y);
  nei[nagh_x][1].push_back(y);
  nei[y][0].push_back(nagh_x);
  nei[nagh_y][1].push_back(x);
  nei[x][0].push_back(nagh_y);
}
void dfs1(long long u) {
  mark1[u] = 1;
  for (auto v : nei[u][1]) {
    if (!mark1[v]) {
      dfs1(v);
    }
  }
  ts.push_back(u);
}
void dfs2(long long u) {
  mark2[u] = 1;
  comp[u] = cnt;
  for (auto v : nei[u][0]) {
    if (!mark2[v]) {
      dfs2(v);
    }
  }
}
bool ch(long long x) {
  long long tmp_cnt = 0;
  cnt = 0;
  for (int i = 0; i <= 6 * m; i++) {
    nei[i][1].clear();
    nei[i][0].clear();
    comp[i] = 0;
    mark1[i] = 0;
    mark2[i] = 0;
    ans[i] = 0;
  }
  for (int i = 0; i < m; i++) {
    if (ed[i + 1].t > x) {
      nei[i + 1][1].push_back(i + 1 + m);
      nei[i + 1 + m][0].push_back(i + 1);
    }
  }
  for (int i = 1; i <= n; i++) {
    mp.clear();
    for (int j = 0; j < adj[i].size(); j++) {
      tmp_cnt++;
      if (j > 0) {
        add_con(N(2 * m + tmp_cnt - 1), N(adj[i][j]));
        add_con(N(2 * m + tmp_cnt - 1), 2 * m + tmp_cnt);
        add_con(N(adj[i][j]), 2 * m + tmp_cnt);
      } else {
        add_con(N(adj[i][j]), 2 * m + tmp_cnt);
      }
      if (!mp[ed[adj[i][j]].c]) {
        mp[ed[adj[i][j]].c] = adj[i][j];
      } else if (mp[ed[adj[i][j]].c] == -1) {
        return false;
      } else {
        add_con(adj[i][j], mp[ed[adj[i][j]].c]);
        mp[ed[adj[i][j]].c] = -1;
      }
    }
  }
  for (int i = 1; i <= 6 * m; i++) {
    if (!mark1[i]) {
      dfs1(i);
    }
  }
  while (!ts.empty()) {
    long long v = ts.back();
    ts.pop_back();
    if (!mark2[v]) {
      cnt++;
      dfs2(v);
    }
  }
  for (int i = 1; i <= m; i++) {
    if (comp[i] == comp[i + m]) {
      return false;
    }
    if (comp[i] > comp[i + m]) {
      ans[i] = 1;
    } else {
      ans[i] = 0;
    }
  }
  for (int i = 2 * m + 1; i <= 4 * m; i++) {
    if (comp[i] == comp[i + 2 * m]) {
      return false;
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> ed[i + 1].u >> ed[i + 1].v >> ed[i + 1].c >> ed[i + 1].t;
    adj[ed[i + 1].u].push_back(i + 1);
    adj[ed[i + 1].v].push_back(i + 1);
  }
  long long l = -1, r = inf;
  while (r - l > 1) {
    long long mid = (l + r) / 2;
    if (ch(mid)) {
      r = mid;
    } else {
      l = mid;
    }
  }
  if (r == inf) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  ch(r);
  long long tmp = 0;
  for (int i = 0; i < m; i++) {
    if (ans[i + 1]) {
      tmp++;
    }
  }
  cout << r << ' ' << tmp << endl;
  for (int i = 0; i < m; i++) {
    if (ans[i + 1]) {
      cout << i + 1 << ' ';
    }
  }
  cout << endl;
}
