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 int N = 4e5 + 9, INF = 1e9 + 9;
int n, m, u[N], v[N], c[N], t[N], num[N];
vector<int> g[N], in[N], out[N], ts;
map<int, int> k;
bool mark[N], be[N];
void add(int v, int u) {
  out[v ^ 1].push_back(u), in[u].push_back(v ^ 1), out[u ^ 1].push_back(v),
      in[v].push_back(u ^ 1);
}
void dfs(int v) {
  mark[v] = 1;
  for (auto u : out[v])
    if (!mark[u]) dfs(u);
  ts.push_back(v);
}
void sfd(int v, int col) {
  num[v] = col;
  for (auto u : in[v])
    if (num[u] == -1) sfd(u, col);
}
bool check(int x) {
  int cc = m;
  ts.clear();
  for (int i = 0; i < N; i++)
    in[i].clear(), out[i].clear(), mark[i] = 0, num[i] = -1, be[i] = false;
  for (int i = 0; i < n; i++) {
    k.clear();
    int pre = -1;
    for (auto e : g[i]) {
      if (pre == -1)
        pre = e;
      else
        add(2 * pre + 1, 2 * e + 1), add(2 * pre + 1, 2 * cc),
            add(2 * e + 1, 2 * cc), pre = cc++;
      if (!k[c[e]])
        k[c[e]] = e + 1;
      else if (k[c[e]] == -1)
        return false;
      else
        add(2 * (k[c[e]] - 1), 2 * e), k[c[e]] = -1;
    }
  }
  for (int i = 0; i < m; i++)
    if (t[i] > x)
      out[2 * i].push_back(2 * i + 1), in[2 * i + 1].push_back(2 * i);
  int v = 2 * cc;
  for (int i = 0; i < v; i++)
    if (!mark[i]) dfs(i);
  int cnt = 0;
  for (int i = v - 1; i >= 0; i--)
    if (num[ts[i]] == -1) sfd(ts[i], cnt++);
  for (int i = 0; i < v; i += 2)
    if (num[i] == num[i + 1])
      return false;
    else if (num[i] > num[i + 1])
      be[i >> 1] = true;
  return true;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++)
    cin >> u[i] >> v[i] >> c[i] >> t[i], u[i]--, v[i]--, g[u[i]].push_back(i),
        g[v[i]].push_back(i);
  int l = -1, r = INF;
  while (r - l > 1) {
    int mid = l + r >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  if (r == INF) return cout << "No\n", 0;
  cout << "Yes\n", check(r);
  int ted = 0;
  for (int i = 0; i < m; i++)
    if (be[i]) ted++;
  cout << r << ' ' << ted << "\n";
  for (int i = 0; i < m; i++)
    if (be[i]) cout << i + 1 << ' ';
}
