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>
int inp() {
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  int sum = 0;
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return sum;
}
int head[300010], nxt[10000010], end[10000010];
int cou = 0, n, m;
void link(int a, int b) {
  nxt[++cou] = head[a];
  head[a] = cou;
  end[cou] = b;
}
std::vector<int> edg[50010];
std::vector<std::pair<int, int> > vec[50010];
std::map<int, int> used;
int pre[50010], suf[50010];
int cnt = 0, tot;
void solve1(int x) {
  if (edg[x].size() <= 1) return;
  pre[0] = edg[x][0] + m;
  suf[edg[x].size() - 1] = edg[x][edg[x].size() - 1] + m;
  for (int i = 1; i < edg[x].size(); i++) {
    pre[i] = ++tot;
    link(pre[i], pre[i - 1]);
    link(pre[i], edg[x][i] + m);
  }
  for (int i = edg[x].size() - 2; i >= 0; i--) {
    suf[i] = ++tot;
    link(suf[i], suf[i + 1]);
    link(suf[i], edg[x][i] + m);
  }
  for (int i = 1; i < edg[x].size(); i++) link(edg[x][i], pre[i - 1]);
  for (int i = 0; i < edg[x].size() - 1; i++) link(edg[x][i], suf[i + 1]);
}
void solve2(int x) {
  if (edg[x].size() <= 1) return;
  pre[0] = edg[x][0];
  suf[edg[x].size() - 1] = edg[x][edg[x].size() - 1];
  for (int i = 1; i < edg[x].size(); i++) {
    pre[i] = ++tot;
    link(pre[i], pre[i - 1]);
    link(pre[i], edg[x][i]);
  }
  for (int i = edg[x].size() - 2; i >= 0; i--) {
    suf[i] = ++tot;
    link(suf[i], suf[i + 1]);
    link(suf[i], edg[x][i]);
  }
  for (int i = 1; i < edg[x].size(); i++) link(edg[x][i] + m, pre[i - 1]);
  for (int i = 0; i < edg[x].size() - 1; i++) link(edg[x][i] + m, suf[i + 1]);
}
int dfn[300010], low[300010], idx;
int st[300010], top = 0, bel[300010];
bool ins[300010], ans[300010];
void tarjan(int cur) {
  ins[cur] = true;
  st[++top] = cur;
  ins[cur] = true;
  dfn[cur] = low[cur] = ++idx;
  for (int x = head[cur]; x != -1; x = nxt[x]) {
    if (!dfn[end[x]]) {
      tarjan(end[x]);
      low[cur] = std::min(low[cur], low[end[x]]);
    } else if (ins[end[x]])
      low[cur] = std::min(low[cur], dfn[end[x]]);
  }
  if (low[cur] == dfn[cur]) {
    cnt++;
    while (st[top] != cur) {
      ins[st[top]] = false;
      bel[st[top]] = cnt;
      top--;
    }
    ins[cur] = false;
    bel[cur] = cnt;
    top--;
  }
}
int num = 0, w[300010];
bool check(int lim) {
  tot = m << 1;
  memset(head, -1, sizeof(head));
  cou = 0;
  for (int i = 1; i <= m; i++)
    if (w[i] > lim) link(i, i + m);
  for (int i = 1; i <= n; i++) edg[i].clear();
  for (int i = 1; i <= num; i++)
    for (int j = 0; j < vec[i].size(); j++)
      edg[vec[i][j].first].push_back(vec[i][j].second);
  for (int i = 1; i <= n; i++) solve1(i);
  for (int i = 1; i <= num; i++) {
    std::vector<int> v2;
    for (int j = 0; j < vec[i].size(); j++) v2.push_back(vec[i][j].first);
    std::sort(v2.begin(), v2.end());
    v2.erase(std::unique(v2.begin(), v2.end()), v2.end());
    for (int j = 0; j < v2.size(); j++) edg[v2[j]].clear();
    for (int j = 0; j < vec[i].size(); j++)
      edg[vec[i][j].first].push_back(vec[i][j].second);
    for (int j = 0; j < v2.size(); j++) solve2(v2[j]);
  }
  cnt = idx = 0;
  memset(dfn, 0, sizeof(dfn));
  for (int i = 1; i <= tot; i++)
    if (!dfn[i]) {
      tarjan(i);
    }
  for (int i = 1; i <= m; i++) {
    if (bel[i] == bel[i + m]) return false;
    ans[i] = (bel[i] < bel[i + m]);
  }
  return true;
}
int main() {
  n = inp();
  m = inp();
  for (int i = 1; i <= m; i++) {
    int u = inp();
    int v = inp();
    int c = inp();
    w[i] = inp();
    if (!used[c]) used[c] = ++num;
    vec[used[c]].push_back(std::make_pair(u, i));
    vec[used[c]].push_back(std::make_pair(v, i));
  }
  int l = 0;
  int r = 1e9 + 1;
  while (l < r) {
    int mid = (l + r) >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  if (l == 1e9 + 1)
    printf("No\n");
  else
    printf("Yes\n%d ", l);
  if (l < 1e9 + 1) {
    check(l);
    std::vector<int> res;
    for (int i = 1; i <= m; i++)
      if (ans[i]) res.push_back(i);
    printf("%d\n", res.size());
    for (int i = 0; i < res.size(); i++) printf("%d ", res[i]);
    putchar('\n');
  }
}
