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;
int N, M, x[50100], comp, y[50100], col[50100], t[50100];
vector<pair<int, int> > m[50100];
int MM;
int s[410000], curr, c[410000], sol[410000];
vector<int> g[410000], gt[410000], v[410000];
bool viz[410000], vz[410000];
void dfs(int x) {
  viz[x] = 1;
  for (auto y : g[x]) {
    if (!viz[y]) dfs(y);
  }
  s[++curr] = x;
}
void dfs2(int x, int comp) {
  viz[x] = 0;
  c[x] = comp;
  v[comp].push_back(x);
  for (int i = 0; i < gt[x].size(); ++i) {
    if (viz[gt[x][i]]) {
      dfs2(gt[x][i], comp);
    }
  }
}
void add_cond(int x, int s1, int y, int s2) {
  g[2 * x + 1 - s1].push_back(2 * y + s2);
  g[2 * y + 1 - s2].push_back(2 * x + s1);
  gt[2 * x + s1].push_back(2 * y + 1 - s2);
  gt[2 * y + s2].push_back(2 * x + 1 - s1);
}
inline int ng(int x) {
  if (x % 2) return x - 1;
  return x + 1;
}
bool f(int x, int val) {
  vz[x] = 1;
  for (auto y : v[x]) {
    if (sol[y] && sol[y] != val) return false;
    sol[y] = val;
  }
  for (auto y : v[x]) {
    y = ng(y);
    if (sol[y] && sol[y] != 3 - val) return false;
    if (!sol[y]) return f(c[y], 3 - val);
  }
  return true;
}
bool check(int T, bool prsol) {
  for (int i = 0; i <= 2 * M + 1; ++i) {
    sol[i] = 0;
    vz[i] = 0;
  }
  for (int i = 1; i <= MM; ++i) {
    if (t[i] > T) {
      sol[2 * i] = 1;
      sol[2 * i + 1] = 2;
    }
  }
  for (int i = 2; i <= 2 * M + 1; ++i) {
    if (sol[i] && !vz[c[i]]) {
      if (!f(c[i], sol[i])) return false;
    }
  }
  for (int i = 1; i <= comp; ++i) {
    if (!vz[i]) {
      if (!f(i, 1)) return false;
    }
  }
  if (prsol) {
    vector<int> sl;
    for (int i = 1; i <= MM; ++i) {
      if (sol[2 * i] == 2) {
        sl.push_back(i);
      }
    }
    cout << sl.size() << "\n";
    for (auto i : sl) {
      cout << i << " ";
    }
  }
  return true;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin >> N >> MM;
  for (int i = 1; i <= MM; ++i) {
    cin >> x[i] >> y[i] >> col[i] >> t[i];
    m[x[i]].push_back(make_pair(col[i], i));
    m[y[i]].push_back(make_pair(col[i], i));
  }
  for (int i = 1; i <= N; ++i) {
    sort(m[i].begin(), m[i].end());
    int cnt = 1, nr = 0;
    for (int j = 1; j < m[i].size(); ++j) {
      if (m[i][j].first == m[i][j - 1].first) {
        ++cnt;
        if (cnt > 2) {
          cout << "No\n";
          return 0;
        }
        ++nr;
        add_cond(m[i][j].second, 0, m[i][j - 1].second, 0);
        if (nr > 1) {
          cout << "No\n";
          return 0;
        }
      } else {
        cnt = 1;
      }
    }
  }
  M = MM;
  for (int n = 1; n <= N; ++n) {
    int k = m[n].size();
    for (int i = 1; i <= k; ++i) {
      if (i > 1) {
        add_cond(M + i, 0, M + i - 1, 1);
      }
      if (i < k) {
        add_cond(M + i, 1, m[n][i].second, 1);
      }
      add_cond(M + i, 0, m[n][i - 1].second, 1);
    }
    M += k;
  }
  for (int i = 2; i <= 2 * M + 1; ++i) {
    if (!viz[i]) dfs(i);
  }
  for (int i = curr; i >= 1; --i) {
    if (viz[s[i]]) {
      dfs2(s[i], ++comp);
    }
  }
  int st = 0, dr = 1000000000, ret = -1;
  while (st <= dr) {
    int mij = (st + dr) / 2;
    if (check(mij, 0)) {
      dr = mij - 1;
      ret = mij;
    } else {
      st = mij + 1;
    }
  }
  if (ret == -1) {
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n" << ret << " ";
  check(ret, 1);
  return 0;
}
