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;
void makemax(int &a, int b) {
  if (a < b) a = b;
}
void imp() {
  cout << "No\n";
  exit(0);
}
class edge {
 public:
  int v, u, c, t;
  int nxt(int first) { return v + u - first; }
};
int n, m;
edge e[100005];
vector<pair<int, int> > E[100005];
map<int, char> bio[100005];
vector<int> v;
vector<int> v2;
vector<int> vr;
void DFS(int id, int c, int p, char clr) {
  int a = lower_bound(E[id].begin(), E[id].end(), pair<int, int>{c, 0}) -
          E[id].begin();
  int b = lower_bound(E[id].begin(), E[id].end(), pair<int, int>{c + 1, 0}) -
          E[id].begin();
  if (b - a > 2) imp();
  if (bio[id][c]) {
    if (id != p && clr != bio[id][c]) imp();
    return;
  }
  bio[id][c] = clr;
  if (id == p && b - a == 2 &&
      e[E[id][a].second].nxt(id) == e[E[id][a + 1].second].nxt(id)) {
    bio[e[E[id][a].second].nxt(id)][c] = 3 - clr;
    v = {e[E[id][a].second].t, e[E[id][a + 1].second].t};
    v2 = {E[id][a].second, E[id][a + 1].second};
    return;
  }
  for (int i = (int)(a); i < (int)(b); ++i)
    if (e[E[id][i].second].nxt(id) != p &&
        !bio[e[E[id][i].second].nxt(id)][c]) {
      v.push_back(e[E[id][i].second].t);
      v2.push_back(E[id][i].second);
      DFS(e[E[id][i].second].nxt(id), c, id, 3 - clr);
      if (id == p) reverse(v.begin(), v.end()), reverse(v2.begin(), v2.end());
    }
}
bool bla[100005];
int main() {
  cin >> n >> m;
  for (int i = (int)(0); i < (int)(m); ++i) {
    scanf("%d%d%d%d", &e[i].v, &e[i].u, &e[i].c, &e[i].t), --e[i].v, --e[i].u;
    E[e[i].v].push_back({e[i].c, i});
    E[e[i].u].push_back({e[i].c, i});
  }
  for (int i = (int)(0); i < (int)(n); ++i) sort(E[i].begin(), E[i].end());
  int R = 0;
  for (int t = (int)(0); t < (int)(n); ++t) {
    for (int i = 0, j = 0; i < (int)E[t].size(); i = j) {
      for (; j < (int)E[t].size() && E[t][i].first == E[t][j].first; ++j)
        ;
      DFS(t, E[t][i].first, t, 1);
      int a[2] = {0, 0};
      for (int k = (int)(0); k < (int)(v.size()); ++k)
        makemax(a[k % 2], v[k]), cerr << "v[k]"
                                      << " = " << v[k] << endl;
      cerr << endl;
      makemax(R, min(a[0], a[1]));
      for (int i = (a[0] > a[1]); i < (int)v2.size(); i += 2)
        vr.push_back(v2[i]);
      v.clear();
      v2.clear();
    }
  }
  for (auto first : vr)
    if (bla[e[first].v]++ || bla[e[first].u]++) imp();
  cout << "Yes\n" << R << " " << vr.size() << endl;
  for (auto first : vr) printf("%d ", first + 1);
  cout << endl;
  return 0;
}
