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 inf = 0x3f3f3f3f;
const long long infLL = 0x3f3f3f3f3f3f3f3fLL;
const int maxn = 100000 + 5;
int psz;
struct Edge {
  int v;
  Edge *next;
} epool[maxn * 4], *e[maxn];
int deg[maxn];
void add_edge(int u, int v) {
  Edge *i = epool + psz++;
  i->v = v, i->next = e[u];
  e[u] = i;
  ++deg[u];
  if ((psz - 1) & 1) add_edge(v, u);
}
int n, m;
int u[maxn], v[maxn], c[maxn], t[maxn];
vector<int> vec[maxn];
bool init() {
  for (int u = 0; u < (n); ++u) {
    bool flag = false;
    map<int, int> mp;
    map<int, int>::iterator p;
    for (__typeof(vec[u].begin()) it = vec[u].begin(); it != vec[u].end();
         ++it) {
      int i = *it;
      p = mp.find(c[i]);
      if (p == mp.end())
        mp[c[i]] = i;
      else if (flag)
        return false;
      else {
        flag = true;
        add_edge(u, n + i);
        add_edge(u, n + p->second);
        p->second = -1;
      }
    }
  }
  return true;
}
int sz, id[maxn];
bool vis[maxn];
int f[maxn][2], pre[maxn][2];
int g[maxn][2], suf[maxn][2];
vector<int> step;
void dfs(int u) {
  id[sz++] = u;
  vis[u] = true;
  for (Edge *i = e[u]; i; i = i->next) {
    int v = i->v;
    if (!vis[v]) dfs(v);
  }
}
void dp(int p, int f[][2], int pre[][2]) {
  while ((p += 2) < sz) {
    f[p][0] = f[p - 2][1];
    pre[p][0] = 1;
    if (f[p - 2][0] < f[p - 2][1]) {
      f[p][1] = max(f[p - 2][0], t[id[p - 1] - n]);
      pre[p][1] = 0;
    } else {
      f[p][1] = max(f[p - 2][1], t[id[p - 1] - n]);
      pre[p][1] = 1;
    }
  }
}
void print(int pre[][2], int i, int o) {
  if (i > 1) print(pre, i - 2, pre[i][o]);
  if (o) step.push_back(id[i - 1] - n);
}
void solve() {
  int ret = 0;
  for (int p = 0; p < (n + m); ++p)
    if (!vis[p] && deg[p] == 1) {
      sz = 0;
      dfs(p);
      if (id[0] < n) {
        f[0][0] = 0, f[0][1] = inf;
        dp(0, f, pre);
        if (sz & 1) {
          ret = max(ret, f[sz - 1][1]);
          print(pre, sz - 1, 1);
        } else if (f[sz - 2][1] < f[sz - 2][0] + t[id[sz - 1] - n]) {
          ret = max(ret, f[sz - 2][1]);
          print(pre, sz - 2, 1);
        } else {
          ret = max(ret, f[sz - 2][0] + t[id[sz - 1] - n]);
          print(pre, sz - 2, 0);
          step.push_back(id[sz - 1] - n);
        }
      } else {
        f[1][0] = 0, f[1][1] = t[id[0] - n];
        dp(1, f, pre);
        if (~sz & 1) {
          ret = max(ret, f[sz - 1][1]);
          print(pre, sz - 1, 1);
        } else if (f[sz - 2][1] < f[sz - 2][0] + t[id[sz - 1] - n]) {
          ret = max(ret, f[sz - 2][1]);
          print(pre, sz - 2, 1);
        } else {
          ret = max(ret, f[sz - 2][0] + t[id[sz - 1] - n]);
          print(pre, sz - 2, 0);
          step.push_back(id[sz - 1] - n);
        }
      }
    }
  for (int p = 0; p < (n + m); ++p)
    if (!vis[p] && deg[p] && p >= n) {
      sz = 0;
      dfs(p);
      if (sz == 2) {
        ret = max(ret, t[id[0] - n]);
        step.push_back(id[0] - n);
        continue;
      }
      f[1][0] = 0, f[1][1] = inf;
      dp(1, f, pre);
      g[1][0] = inf, g[1][1] = t[id[0] - n];
      dp(1, g, suf);
      if (g[sz - 3][0] + t[id[sz - 2] - n] < g[sz - 3][1] &&
          g[sz - 3][0] + t[id[sz - 2] - n] < f[sz - 1][1]) {
        ret = max(ret, g[sz - 3][0] + t[id[sz - 2] - n]);
        print(suf, sz - 3, 0);
        step.push_back(id[sz - 1] - n);
      } else if (g[sz - 3][1] < f[sz - 1][1]) {
        ret = max(ret, g[sz - 3][1]);
        print(suf, sz - 3, 1);
      } else {
        ret = max(ret, f[sz - 1][1]);
        print(pre, sz - 1, 1);
      }
    }
  printf("%d %d\n", ret, (int)step.size());
  for (__typeof(step.begin()) it = step.begin(); it != step.end(); ++it)
    printf("%d%c", *it + 1, " \n"[it == --step.end()]);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (m); ++i) {
    scanf("%d%d%d%d", &u[i], &v[i], &c[i], &t[i]);
    --u[i], --v[i];
    vec[u[i]].push_back(i);
    vec[v[i]].push_back(i);
  }
  if (!init()) {
    puts("No");
  } else {
    puts("Yes");
    solve();
  }
  return 0;
}
