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 MAXN = 5e4 + 6.66;
const int MAX = 8 * MAXN;
struct EDGE {
  int b;
  int e;
  int t;
  int c;
  EDGE() { b = e = t = c = -1; };
  EDGE(int b, int e, int c, int t) : b(b), e(e), t(t), c(c){};
} eds[MAXN];
vector<int> ed[MAX];
vector<int> rev[MAX];
vector<int> topo;
int scc[MAX];
int ans[MAX];
bool mark[MAX];
map<int, int> col[MAXN];
int prv[MAXN];
inline int self(int x) { return x << 3; };
inline int matt(int x) { return x ^ 4; };
inline int mat(int x) { return x ^ 2; };
inline int other(int x) { return x ^ 1; };
istream& operator>>(istream& I, EDGE& e) {
  int x, y, z, w;
  I >> x >> y >> z >> w;
  e = EDGE(x, y, z, w);
  return I;
}
void add_edge(int x, int y) {
  ed[x].push_back(y);
  rev[y].push_back(x);
}
void add_clause(int x, int y) {
  add_edge(other(x), y);
  add_edge(other(y), x);
}
void add_linked(int a, int b, int prv, int ss) {
  add_clause(other(b), a);
  if (~prv) {
    add_clause(other(b), other(prv));
    add_clause(other(b), ss);
  }
}
void matching_clause(int v, int w, int i) {
  if (~prv[v]) {
    int t = other(mat(self(i)));
    add_clause(other(prv[v]), w);
    add_clause(other(prv[v]), other(self(i)));
  }
}
void build(int n, int m, int k) {
  for (int i = 0; i < m; i++) {
    EDGE e = eds[i];
    add_clause(other(self(i)), mat(self(i)));
    matching_clause(e.b, mat(self(i)), i);
    matching_clause(e.e, matt(self(i)), i);
    if (col[e.b].count(e.c)) add_clause(self(i), self(col[e.b][e.c]));
    if (col[e.e].count(e.c)) add_clause(self(i), self(col[e.e][e.c]));
    col[e.e][e.c] = col[e.b][e.c] = i;
    prv[e.b] = mat(self(i));
    prv[e.e] = matt(self(i));
    if (e.t > k) {
      add_clause(other(self(i)), other(self(i)));
    }
  }
}
bool check(int n, int m, int k) {
  for (int i = 0; i < MAXN; i++) col[i].clear();
  for (int i = 0; i < m; i++)
    col[eds[i].e][eds[i].c]++, col[eds[i].b][eds[i].c]++;
  for (int i = 0; i < MAXN; i++)
    for (auto w : col[i])
      if (w.second > 2) return false;
  return true;
}
void topo_dfs(int v) {
  mark[v] = true;
  for (auto w : ed[v])
    if (!mark[w]) topo_dfs(w);
  topo.push_back(v);
}
void scc_dfs(int v, int I) {
  mark[v] = false;
  scc[v] = I;
  for (auto w : rev[v])
    if (mark[w]) scc_dfs(w, I);
}
bool solve(int n, int m, int k) {
  if (!check(n, m, k)) return false;
  for (int i = 0; i < MAXN; i++) col[i].clear();
  for (int i = 0; i < MAXN; i++) ed[i].clear();
  for (int i = 0; i < MAXN; i++) rev[i].clear();
  memset(mark, 0, sizeof mark);
  memset(prv, -1, sizeof prv);
  memset(scc, 0, sizeof scc);
  topo.clear();
  build(n, m, k);
  for (int i = 0; i < m; i++) {
    if (!mark[self(i)]) topo_dfs(self(i));
    if (!mark[other(self(i))]) topo_dfs(other(self(i)));
    if (!mark[mat(self(i))]) topo_dfs(mat(self(i)));
    if (!mark[other(mat(self(i)))]) topo_dfs(other(mat(self(i))));
    if (!mark[mat(self(i))]) topo_dfs(matt(self(i)));
    if (!mark[other(mat(self(i)))]) topo_dfs(other(matt(self(i))));
  }
  reverse(topo.begin(), topo.end());
  for (auto w : topo)
    if (mark[w]) scc_dfs(w, w);
  reverse(topo.begin(), topo.end());
  for (auto w : topo)
    if (scc[w] == scc[other(w)]) return false;
  return true;
}
void generate(int n, int m, int k) {
  if (!solve(n, m, k)) {
    cout << "No" << endl;
    return;
  }
  cout << "Yes" << endl;
  for (auto w : topo) {
    if (w != scc[w] || ans[scc[w]]) continue;
    ans[scc[w]] = 1;
    ans[scc[other(w)]] = 2;
  }
  cout << k << " ";
  vector<int> Ans;
  for (int i = 0; i < m; i++)
    if (ans[scc[self(i)]] % 2 == 1) Ans.push_back(i + 1);
  cout << Ans.size() << endl;
  for (auto w : Ans) cout << w << " ";
  cout << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) cin >> eds[i];
  int l = 0, r = 1e9 + 7;
  while (l < r) {
    int mid = l + ((r - l) >> 1);
    if (solve(n, m, mid))
      r = mid;
    else
      l = mid + 1;
  }
  generate(n, m, r);
  return 0;
}
