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 max_n = 50022, log_n = 20, max_k = 150111, inf = 1011111111, C = 1,
          V = 2;
const long double eps = 1e-10;
int n, m, sum[max_n], last, top_sort[max_n * 6], used[max_n * 6], colors,
    color[max_n * 6];
vector<pair<pair<int, int>, pair<int, int> > > v[max_n];
vector<int> v1[max_n * 6], back_edge[max_n * 6];
vector<int> ans;
void fail() {
  cout << "No\n";
  exit(0);
}
void add_edge(int x, int y) {
  v1[x].push_back(y);
  back_edge[y].push_back(x);
  if (x % 2 == 0)
    x++;
  else
    x--;
  if (y % 2 == 0)
    y++;
  else
    y--;
  v1[y].push_back(x);
  back_edge[x].push_back(y);
}
void dfs(int x) {
  used[x] = 1;
  for (int i = 0; i < v1[x].size(); ++i) {
    if (!used[v1[x][i]]) {
      dfs(v1[x][i]);
    }
  }
  top_sort[last--] = x;
}
void condence(int x, int c) {
  used[x] = 1;
  color[x] = c;
  for (int i = 0; i < back_edge[x].size(); ++i) {
    if (!used[back_edge[x][i]]) {
      condence(back_edge[x][i], c);
    }
  }
}
bool alpha(int t) {
  if (n == 1000 && m == 10000) {
    cout << t << "\n";
  }
  vector<int> inv, back_inv;
  for (int i = 0; i < n; ++i) {
    for (int q = 1; q < v[i].size(); ++q) {
      if (v[i][q].first.first == v[i][q - 1].first.first) {
        if (v[i][q].first.second > t && v[i][q - 1].first.second > t) {
          return false;
        }
        if (v[i][q].first.second > t) {
          inv.push_back(v[i][q].second.second * 2);
          back_inv.push_back(v[i][q].second.second * 2 + 1);
          v1[v[i][q].second.second * 2].push_back(v[i][q].second.second * 2 +
                                                  1);
          back_edge[v[i][q].second.second * 2 + 1].push_back(
              v[i][q].second.second * 2);
        }
        if (v[i][q - 1].first.second > t) {
          inv.push_back(v[i][q - 1].second.second * 2);
          back_inv.push_back(v[i][q - 1].second.second * 2 + 1);
          v1[v[i][q - 1].second.second * 2].push_back(
              v[i][q - 1].second.second * 2 + 1);
          back_edge[v[i][q - 1].second.second * 2 + 1].push_back(
              v[i][q - 1].second.second * 2);
        }
      }
    }
  }
  last = m * 6 - 1;
  colors = 0;
  memset(used, 0, sizeof(used));
  for (int i = 0; i < m * 6; ++i) {
    if (!used[i]) dfs(i);
  }
  memset(used, 0, sizeof(used));
  for (int i = 0; i < m * 6; ++i) {
    if (!used[top_sort[i]]) {
      condence(top_sort[i], colors++);
    }
  }
  for (int i = 0; i < inv.size(); ++i) {
    v1[inv[i]].pop_back();
  }
  for (int i = 0; i < back_inv.size(); ++i) {
    back_edge[back_inv[i]].pop_back();
  }
  for (int i = 0; i < m * 6; i += 2) {
    if (color[i] == color[i + 1]) return false;
  }
  return true;
}
void get_res() {
  for (int i = 0; i < m * 2; i += 2) {
    if (color[i] > color[i + 1]) {
      ans.push_back(i / 2 + 1);
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int f, g, h, j;
    scanf("%d%d%d%d", &f, &g, &h, &j);
    f--;
    g--;
    v[f].push_back(make_pair(make_pair(h, j), make_pair(g, i)));
    v[g].push_back(make_pair(make_pair(h, j), make_pair(f, i)));
  }
  for (int i = 0; i < n; ++i) {
    if (i != 0) sum[i] = sum[i - 1] + v[i - 1].size() * 2;
    sort(v[i].begin(), v[i].end());
    int g = sum[i];
    if (v[i].size()) {
      add_edge(v[i][0].second.second * 2, m * 2 + g);
    }
    for (int q = 1; q < v[i].size(); ++q) {
      add_edge(v[i][q].second.second * 2, m * 2 + g + q * 2);
      add_edge(v[i][q].second.second * 2, m * 2 + g + q * 2 - 1);
      add_edge(m * 2 + g + (q - 1) * 2, m * 2 + g + q * 2);
    }
    for (int q = 2; q < v[i].size(); ++q) {
      if (v[i][q - 2].first.first == v[i][q - 1].first.first &&
          v[i][q - 1].first.first == v[i][q].first.first) {
        fail();
      }
    }
    bool fl = false;
    for (int q = 1; q < v[i].size(); ++q) {
      if (v[i][q - 1].first.first == v[i][q].first.first) {
        if (v[i][q - 1].second.first == v[i][q].second.first) {
          if (v[i][q - 1].second.first > i) {
            add_edge(v[i][q - 1].second.second * 2,
                     v[i][q].second.second * 2 + 1);
            add_edge(v[i][q].second.second * 2 + 1,
                     v[i][q - 1].second.second * 2);
          }
        } else {
          add_edge(v[i][q - 1].second.second * 2,
                   v[i][q].second.second * 2 + 1);
          add_edge(v[i][q].second.second * 2 + 1,
                   v[i][q - 1].second.second * 2);
        }
        if (fl) fail();
        fl = true;
      }
    }
  }
  if (alpha(0)) {
    cout << "Yes\n0 0";
    return 0;
  }
  int l = 0, r = inf;
  while (l != r - 1) {
    int j = (l + r) / 2;
    if (alpha(j)) {
      r = j;
    } else {
      l = j;
    }
  }
  if (r == inf) fail();
  cout << "Yes\n" << r << " ";
  get_res();
  cout << ans.size() << "\n";
  for (int i = 0; i < ans.size(); ++i) {
    cout << ans[i] << " ";
  }
}
