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>
#pragma GCC optimize("Ofast")
using namespace std;
constexpr long long mod = 1000000007;
const long long INF = mod * mod;
const long double eps = 1e-12;
const long double pi = acosl(-1.0);
long long mod_pow(long long x, long long n, long long m = mod) {
  if (n < 0) {
    long long res = mod_pow(x, -n, m);
    return mod_pow(res, m - 2, m);
  }
  if (abs(x) >= m) x %= m;
  if (x < 0) x += m;
  long long res = 1;
  while (n) {
    if (n & 1) res = res * x % m;
    x = x * x % m;
    n >>= 1;
  }
  return res;
}
struct modint {
  long long n;
  modint() : n(0) { ; }
  modint(long long m) : n(m) {
    if (n >= mod)
      n %= mod;
    else if (n < 0)
      n = (n % mod + mod) % mod;
  }
  operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) {
  a.n += b.n;
  if (a.n >= mod) a.n -= mod;
  return a;
}
modint operator-=(modint& a, modint b) {
  a.n -= b.n;
  if (a.n < 0) a.n += mod;
  return a;
}
modint operator*=(modint& a, modint b) {
  a.n = ((long long)a.n * b.n) % mod;
  return a;
}
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, long long n) {
  if (n == 0) return modint(1);
  modint res = (a * a) ^ (n / 2);
  if (n % 2) res = res * a;
  return res;
}
long long inv(long long a, long long p) {
  return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
modint operator/=(modint& a, modint b) {
  a = a / b;
  return a;
}
const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
  fact[0] = modint(1);
  for (int i = 0; i < max_n - 1; i++) {
    fact[i + 1] = fact[i] * modint(i + 1);
  }
  factinv[max_n - 1] = modint(1) / fact[max_n - 1];
  for (int i = max_n - 2; i >= 0; i--) {
    factinv[i] = factinv[i + 1] * modint(i + 1);
  }
}
modint comb(int a, int b) {
  if (a < 0 || b < 0 || a < b) return 0;
  return fact[a] * factinv[b] * factinv[a - b];
}
modint combP(int a, int b) {
  if (a < 0 || b < 0 || a < b) return 0;
  return fact[a] * factinv[a - b];
}
struct edge2 {
  int to;
  long long cap;
  int rev;
};
struct Dinic {
 private:
  int n;
  vector<vector<edge2>> v;
  vector<int> dist, iter;

 public:
  Dinic(int sz) : n(sz), v(sz), dist(sz), iter(sz) {}
  void addedge(int from, int to, long long cap) {
    int x = v[to].size(), y = v[from].size();
    v[from].push_back({to, cap, x});
    v[to].push_back({from, 0, y});
  }
  void bfs(int s) {
    fill(dist.begin(), dist.end(), -1);
    queue<int> q;
    dist[s] = 0;
    q.push(s);
    while (q.size()) {
      int x = q.front();
      q.pop();
      for (int i = 0; i < v[x].size(); i++) {
        edge2& e = v[x][i];
        if (e.cap > 0 && dist[e.to] < 0) {
          dist[e.to] = dist[x] + 1;
          q.push(e.to);
        }
      }
    }
  }
  long long dfs(int x, int t, long long f) {
    if (x == t) return f;
    for (int& i = iter[x]; i < (int)v[x].size(); ++i) {
      edge2& e = v[x][i];
      if (e.cap > 0 && dist[x] < dist[e.to]) {
        long long d = dfs(e.to, t, min(f, e.cap));
        if (d > 0) {
          e.cap -= d;
          v[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }
  long long max_flow(int s, int t) {
    long long flow = 0;
    while (1) {
      bfs(s);
      if (dist[t] < 0) return flow;
      fill(iter.begin(), iter.end(), 0);
      long long f;
      while ((f = dfs(s, t, 1LL << 62)) > 0) flow += f;
    }
  }
  vector<int> tos(int le, int ri) {
    vector<int> res;
    for (int i = le; i < ri; i++)
      for (edge2 e : v[i]) {
        if (e.cap == 0 && e.to < le) {
          res.push_back(e.to);
        }
      }
    return res;
  }
};
struct edge {
  int to, c, t, id;
};
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m), c(m), t(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i] >> t[i];
    a[i]--;
    b[i]--;
  }
  vector<int> col = c;
  sort((col).begin(), (col).end());
  col.erase(unique((col).begin(), (col).end()), col.end());
  for (int i = 0; i < m; i++) {
    c[i] = lower_bound((col).begin(), (col).end(), c[i]) - col.begin();
  }
  vector<int> tim = t;
  tim.push_back(0);
  sort((tim).begin(), (tim).end());
  tim.erase(unique((tim).begin(), (tim).end()), tim.end());
  for (int i = 0; i < m; i++) {
    t[i] = lower_bound((tim).begin(), (tim).end(), t[i]) - tim.begin();
  }
  vector<vector<int>> cs(col.size());
  for (int i = 0; i < m; i++) {
    cs[c[i]].push_back(i);
  }
  vector<int> num(n);
  vector<bool> used(n);
  vector<vector<edge>> g(n);
  int ans = 0;
  vector<pair<pair<int, int>, pair<int, int>>> mem1;
  vector<pair<vector<int>, vector<int>>> memid1;
  vector<pair<pair<int, int>, pair<int, int>>> mem2;
  vector<pair<vector<int>, vector<int>>> memid2;
  vector<int> ansid;
  for (int i = 0; i < col.size(); i++) {
    vector<int> ids;
    for (int id : cs[i]) {
      g[a[id]].push_back({b[id], c[id], t[id], id});
      g[b[id]].push_back({a[id], c[id], t[id], id});
      ids.push_back(a[id]);
      ids.push_back(b[id]);
    }
    sort((ids).begin(), (ids).end());
    ids.erase(unique((ids).begin(), (ids).end()), ids.end());
    queue<int> q;
    for (int j = 0; j < ids.size(); j++) {
      if (used[ids[j]]) continue;
      q.push(ids[j]);
      used[ids[j]] = true;
      vector<int> cur;
      while (!q.empty()) {
        int v = q.front();
        q.pop();
        cur.push_back(v);
        for (edge e : g[v]) {
          if (!used[e.to]) {
            used[e.to] = true;
            q.push(e.to);
          }
        }
      }
      int cnt = 0;
      for (int id : cur) {
        if (g[id].size() > 2) {
          cout << "No\n";
          return;
        }
        cnt += g[id].size();
      }
      cnt /= 2;
      if (cnt == 1) continue;
      if (cnt > cur.size()) {
        cout << "No\n";
        return;
      } else {
        int start = cur[0];
        for (int id : cur)
          if (g[id].size() == 1) start = id;
        vector<int> rw;
        rw.push_back(start);
        rw.push_back(g[start][0].to);
        int fr = start, sc = g[start][0].to;
        vector<int> costs;
        vector<int> ansids;
        costs.push_back(g[start][0].t);
        ansids.push_back(g[start][0].id);
        for (int j = 0; j < cur.size() - 2; j++) {
          int nex;
          if (g[sc][0].to != fr) {
            nex = g[sc][0].to;
            costs.push_back(g[sc][0].t);
            ansids.push_back(g[sc][0].id);
          } else {
            nex = g[sc][1].to;
            costs.push_back(g[sc][1].t);
            ansids.push_back(g[sc][1].id);
          }
          rw.push_back(nex);
          fr = sc, sc = nex;
        }
        if (cnt == cur.size()) {
          costs.push_back(g[start][1].t);
          ansids.push_back(g[start][1].id);
        }
        int t0 = 0, t1 = 0;
        for (int i = 0; i < costs.size(); i++) {
          if (i % 2 == 0)
            t0 = max(t0, costs[i]);
          else
            t1 = max(t1, costs[i]);
        }
        if (cnt == cur.size()) {
          if (cur.size() % 2) {
            cout << "No\n";
            return;
          } else {
            for (int id : cur) num[id]++;
            ans = max(ans, min(tim[t0], tim[t1]));
            if (t0 < t1) {
              for (int j = 0; j < ansids.size(); j += 2) {
                ansid.push_back(ansids[j]);
              }
            } else {
              for (int j = 1; j < ansids.size(); j += 2) {
                ansid.push_back(ansids[j]);
              }
            }
          }
        } else {
          vector<int> ev, od;
          for (int j = 0; j < ansids.size(); j++) {
            if (j % 2 == 0)
              ev.push_back(ansids[j]);
            else
              od.push_back(ansids[j]);
          }
          for (int j = 1; j < rw.size() - 1; j++) num[rw[j]]++;
          if (rw.size() % 2 == 0) {
            mem2.push_back({{t0, t1}, {rw[0], rw.back()}});
            memid2.push_back({ev, od});
          } else {
            mem1.push_back({{t0, t1}, {rw[0], rw.back()}});
            memid1.push_back({ev, od});
          }
        }
      }
    }
    for (int id : ids) {
      used[id] = false;
      g[id].clear();
    }
  }
  for (int i = 0; i < n; i++)
    if (num[i] > 1) {
      cout << "No\n";
      return;
    }
  int le = -1, ri = tim.size();
  while (ri - le > 1) {
    int mid = (le + ri) / 2;
    Dinic dc(n + mem1.size() + 2);
    vector<int> cop = num;
    bool valid = true;
    for (auto p : mem2) {
      if (p.first.second <= mid) {
      } else {
        if (p.first.first <= mid) {
          cop[p.second.first]++;
          cop[p.second.second]++;
        }
      }
    }
    for (int i = 0; i < n; i++)
      if (cop[i] > 1) valid = false;
    int sta = n, goa = n + 1;
    if (valid) {
      for (int i = 0; i < mem1.size(); i++) {
        auto p = mem1[i];
        dc.addedge(sta, i + n, 1);
        if (p.first.first <= mid) {
          dc.addedge(i + n, p.second.first, 1);
        }
        if (p.first.second <= mid) {
          dc.addedge(i + n, p.second.second, 1);
        }
      }
      for (int i = 0; i < n; i++)
        if (cop[i] == 0) dc.addedge(i, goa, 1);
      int f = dc.max_flow(sta, goa);
      if (f != mem1.size()) valid = false;
    }
    if (valid)
      ri = mid;
    else
      le = mid;
  }
  if (ri == tim.size()) {
    cout << "No"
         << "\n";
    return;
  }
  int mid = ri;
  Dinic dc(n + mem1.size() + 2);
  vector<int> cop = num;
  for (int i = 0; i < mem2.size(); i++) {
    auto p = mem2[i];
    if (p.first.second <= mid) {
      for (int id : memid2[i].second) {
        ansid.push_back(id);
      }
    } else {
      if (p.first.first <= mid) {
        cop[p.second.first]++;
        cop[p.second.second]++;
        for (int id : memid2[i].first) {
          ansid.push_back(id);
        }
      }
    }
  }
  int sta = n, goa = n + 1;
  for (int i = 0; i < mem1.size(); i++) {
    auto p = mem1[i];
    dc.addedge(sta, i + n, 1);
    if (p.first.first <= mid) {
      dc.addedge(i + n, p.second.first, 1);
    }
    if (p.first.second <= mid) {
      dc.addedge(i + n, p.second.second, 1);
    }
  }
  for (int i = 0; i < n; i++)
    if (cop[i] == 0) dc.addedge(i, goa, 1);
  int f = dc.max_flow(sta, goa);
  vector<int> ts = dc.tos(n, n + mem1.size());
  for (int i = 0; i < mem1.size(); i++) {
    auto p = mem1[i];
    if (p.second.first == ts[i]) {
      for (int id : memid1[i].first) ansid.push_back(id);
    } else {
      for (int id : memid1[i].second) ansid.push_back(id);
    }
  }
  ans = max(ans, tim[ri]);
  cout << "Yes\n";
  cout << ans << " " << ansid.size() << "\n";
  sort((ansid).begin(), (ansid).end());
  for (int j = 0; j < ansid.size(); j++) {
    if (j > 0) cout << " ";
    cout << ansid[j] + 1;
  }
  cout << "\n";
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
