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 = 5e5 + 5;
int n, m;
namespace sat {
int cnt;
int comp[N];
bool h[N];
vector<int> nd;
vector<int> v[N], t[N];
void del(int x, int y) {
  v[x].pop_back();
  t[y].pop_back();
}
void add(int x, int y) {
  v[x].push_back(y);
  t[y].push_back(x);
}
void clause(int x, int y) {
  add(2 * x + 1, 2 * y);
  add(2 * y + 1, 2 * x);
}
void kill(int x, int y) {
  del(2 * x + 1, 2 * y);
  del(2 * y + 1, 2 * x);
}
void dfs(int x) {
  h[x] = 1;
  for (auto u : v[x])
    if (!h[u]) dfs(u);
  nd.push_back(x);
}
void dfs2(int x) {
  h[x] = 1;
  comp[x] = cnt;
  for (auto u : t[x])
    if (!h[u]) dfs2(u);
}
bool check() {
  cnt = 0;
  nd.clear();
  memset(h, 0, sizeof(h));
  for (int i = 0; i < 450000; i++)
    if (!h[i]) dfs(i);
  reverse(nd.begin(), nd.end());
  memset(h, 0, sizeof(h));
  for (auto i : nd) {
    if (!h[i]) {
      cnt++;
      dfs2(i);
    }
  }
  for (int i = 0; i < 450000; i++)
    if (comp[i] == comp[i ^ 1]) return 0;
  return 1;
}
void create() {
  vector<int> res;
  for (int i = 2; i <= 2 * m; i += 2) {
    if (comp[i] > comp[i ^ 1]) res.push_back(i / 2);
  }
  printf("%d\n", res.size());
  for (auto x : res) printf("%d ", x);
  puts("");
}
}  // namespace sat
vector<int> v[N];
map<pair<int, int>, vector<int> > M;
vector<pair<pair<int, int>, pair<int, int> > > edge;
bool f(int x) {
  for (auto e : edge) {
    if (e.second.second > x)
      sat ::add(e.second.first * 2, e.second.first * 2 + 1);
  }
  bool res = sat ::check();
  for (auto e : edge) {
    if (e.second.second > x)
      sat ::del(e.second.first * 2, e.second.first * 2 + 1);
  }
  return res;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y, c, t;
    scanf("%d %d %d %d", &x, &y, &c, &t);
    if (M[{c, x}].size() > 1 or M[{c, y}].size() > 1) {
      puts("No");
      return 0;
    }
    for (auto j : M[{c, x}]) sat ::clause(i, j);
    for (auto j : M[{c, y}]) sat ::clause(i, j);
    M[{c, x}].push_back(i);
    M[{c, y}].push_back(i);
    edge.push_back({{x, y}, {i, t}});
    v[x].push_back(i);
    v[y].push_back(i);
  }
  int nw = m + 1;
  for (int i = 1; i <= n; i++) {
    int in = nw;
    for (auto x : v[i]) {
      sat ::add(2 * x, 2 * nw);
      if (nw > in) {
        sat ::add(2 * x, 2 * (nw - 1) + 1);
        sat ::add(2 * (nw - 1), 2 * nw);
      }
      ++nw;
    }
  }
  int l = 0, r = 1e9;
  while (l < r) {
    int mid = (l + r) >> 1;
    if (f(mid))
      r = mid;
    else
      l = mid + 1;
  }
  f(l);
  puts("Yes");
  printf("%d ", l);
  sat ::create();
  return 0;
}
