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;
template <class T>
void deba(T *a, int n) {
  for (int i = 0; i < n; i++) cout << a[i] << ' ';
  cout << '\n';
}
const int N = 5e4 + 10, M = 5e4 + 10;
long long n, m, c[N], t[N], num, ans[N];
vector<pair<long long, long long> > e3[N];
vector<long long> e2[M];
bool mark[M];
vector<long long> e[M], er[M], topSort;
long long topSort_num[M], comp[M], cnt_comp;
void add(long long x, long long y) {
  e2[x ^ 1].push_back(y);
  e2[y ^ 1].push_back(x);
}
void topol(long long x) {
  mark[x] = 1;
  for (auto u : e[x])
    if (!mark[u]) topol(u);
  topSort.push_back(x);
  topSort_num[x] = topSort.size();
}
void dfs(long long x) {
  comp[x] = cnt_comp;
  for (auto u : er[x])
    if (!comp[u]) dfs(u);
}
bool check(long long x, bool exx = 0) {
  topSort.clear();
  memset(mark, 0, sizeof(mark));
  memset(comp, 0, sizeof(comp));
  cnt_comp = 1;
  for (int i = 0; i < 2 * num; i++) e[i] = e2[i];
  for (int i = 0; i < m; i++)
    if (t[i] > x) e[2 * i + 1].push_back(2 * i);
  for (int i = 0; i < 2 * num; i++)
    if (!mark[i]) topol(i);
  reverse(topSort.begin(), topSort.end());
  for (int i = 0; i < 2 * num; i++) er[i].clear();
  for (int i = 0; i < 2 * num; i++)
    for (auto u : e[i]) er[u].push_back(i);
  for (auto u : topSort)
    if (!comp[u]) {
      dfs(u);
      cnt_comp++;
    }
  for (int i = 0; i < m; i++) {
    if (comp[2 * i] == comp[2 * i + 1]) return 0;
    if (comp[2 * i + 1] > comp[2 * i])
      ans[i] = 1;
    else
      ans[i] = 0;
  }
  return 1;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  num = m;
  for (int i = 0; i < m; i++) {
    long long v, u;
    cin >> v >> u >> c[i] >> t[i];
    e3[v].push_back({c[i], i});
    e3[u].push_back({c[i], i});
  }
  for (int i = 1; i < n + 1; i++) {
    if (!e3[i].size()) continue;
    bool flg = 0;
    long long id;
    sort(e3[i].begin(), e3[i].end());
    for (int j = 1; j < e3[i].size(); j++) {
      if (e3[i][j].first == e3[i][j - 1].first && flg) {
        cout << "No";
        return 0;
      }
      if (e3[i][j].first == e3[i][j - 1].first) flg = 1, id = j;
    }
    if (flg) add(2 * e3[i][id].second + 1, 2 * e3[i][id - 1].second + 1);
    long long lst = e3[i][0].second;
    for (int j = 1; j < e3[i].size(); j++) {
      long long ex = e3[i][j].second;
      add(2 * lst, 2 * ex);
      add(2 * ex, 2 * num + 1);
      add(2 * lst, 2 * num + 1);
      lst = num++;
    }
  }
  long long l = -1, r = N * 10000;
  while (r - l > 1) {
    long long mid = (l + r) / 2;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  if (r == N * 10000) {
    cout << "No";
    return 0;
  }
  check(r, 1);
  long long res = 0;
  for (int i = 0; i < m; i++) res += ans[i];
  cout << "Yes\n" << r << " " << res << "\n";
  for (int i = 0; i < m; i++)
    if (ans[i]) cout << i + 1 << " ";
  cin >> n;
  return 0;
}
