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 = 5e4 + 5;
int n, m, v[N], u[N], c[N], t[N], tw[N], co, color[N << 1];
unordered_map<int, vector<int> > mp[N];
bool visited[N << 1];
vector<int> topol;
vector<int> out[N << 1], in[N << 1];
void sfd(int v) {
  visited[v] = 1;
  color[v] = co;
  for (auto u : in[v])
    if (!visited[u]) sfd(u);
}
void dfs(int v) {
  visited[v] = 1;
  for (auto u : out[v])
    if (!visited[u]) dfs(u);
  topol.push_back(v);
}
bool check(int x) {
  for (int i = 0; i < N; i++) {
    mp[i].clear();
    out[i << 1].clear();
    out[i << 1 | 1].clear();
    in[i << 1].clear();
    in[i << 1 | 1].clear();
  }
  for (int i = 0; i < m; i++) {
    mp[u[i]][c[i]].push_back(i);
    mp[v[i]][c[i]].push_back(i);
    if (mp[u[i]][c[i]].size() == 2) {
      out[i << 1].push_back(mp[u[i]][c[i]][0] << 1 | 1);
      in[mp[u[i]][c[i]][0] << 1 | 1].push_back(i << 1);
      out[mp[u[i]][c[i]][0] << 1].push_back(i << 1 | 1);
      in[i << 1 | 1].push_back(mp[u[i]][c[i]][0] << 1);
    }
    if (mp[v[i]][c[i]].size() == 2) {
      out[i << 1].push_back(mp[v[i]][c[i]][0] << 1 | 1);
      in[mp[v[i]][c[i]][0] << 1 | 1].push_back(i << 1);
      out[mp[v[i]][c[i]][0] << 1].push_back(i << 1 | 1);
      in[i << 1 | 1].push_back(mp[v[i]][c[i]][0] << 1);
    }
    if (mp[u[i]][c[i]].size() >= 3 || mp[v[i]][c[i]].size() >= 3) return 0;
    if (t[i] > x) {
      out[i << 1 | 1].push_back(i << 1);
      in[i << 1].push_back(i << 1 | 1);
    }
  }
  memset(visited, 0, N << 1);
  topol.clear();
  for (int i = 0; i < 2 * N; i++)
    if (!visited[i]) dfs(i);
  memset(visited, 0, N << 1);
  reverse(topol.begin(), topol.end());
  for (auto x : topol)
    if (!visited[x]) sfd(x), co++;
  for (int i = 0; i < N; i++)
    if (color[i << 1] == color[i << 1 | 1]) return 0;
  return 1;
}
void make(int x) {
  cout << "Yes\n";
  for (int i = 0; i < N; i++) {
    mp[i].clear();
    out[i << 1].clear();
    out[i << 1 | 1].clear();
    in[i << 1].clear();
    in[i << 1 | 1].clear();
  }
  for (int i = 0; i < m; i++) {
    mp[u[i]][c[i]].push_back(i);
    mp[v[i]][c[i]].push_back(i);
    if (mp[u[i]][c[i]].size() == 2) {
      out[i << 1].push_back(mp[u[i]][c[i]][0] << 1 | 1);
      in[mp[u[i]][c[i]][0] << 1 | 1].push_back(i << 1);
      out[mp[u[i]][c[i]][0] << 1].push_back(i << 1 | 1);
      in[i << 1 | 1].push_back(mp[u[i]][c[i]][0] << 1);
    }
    if (mp[v[i]][c[i]].size() == 2) {
      out[i << 1].push_back(mp[v[i]][c[i]][0] << 1 | 1);
      in[mp[v[i]][c[i]][0] << 1 | 1].push_back(i << 1);
      out[mp[v[i]][c[i]][0] << 1].push_back(i << 1 | 1);
      in[i << 1 | 1].push_back(mp[v[i]][c[i]][0] << 1);
    }
    if (t[i] > x) {
      out[i << 1 | 1].push_back(i << 1);
      in[i << 1].push_back(i << 1 | 1);
    }
  }
  memset(visited, 0, N << 1);
  topol.clear();
  for (int i = 0; i < 2 * N; i++)
    if (!visited[i]) dfs(i);
  memset(visited, 0, N << 1);
  reverse(topol.begin(), topol.end());
  for (auto x : topol)
    if (!visited[x]) sfd(x), co++;
  vector<int> ans;
  for (int i = 0; i < m * 2; i++)
    if (color[i << 1] < color[i << 1 | 1]) ans.push_back(i + 1);
  cout << x << " " << ans.size() << '\n';
  for (auto num : ans) cout << num << " ";
  cout << '\n';
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> v[i] >> u[i] >> c[i] >> t[i];
    v[i]--;
    u[i]--;
    c[i]--;
  }
  int l = -1, r = 1e9 + 5;
  while (r - l > 1) {
    int mid = l + r >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  if (r == 1e9 + 5) {
    cout << "No\n";
    return 0;
  } else
    make(r);
}
