#include <bits/stdc++.h>
using namespace std;
int n, L, M;
pair<pair<int, int>, pair<int, int> > ramps[500000];
int xs[500010 * 2];
vector<pair<int, int> > edges[500010 * 2];
int dist[500010 * 2], pre[500010 * 2];
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    Q;
int used[500010];
int dijkstra(int s, int t) {
  fill(dist, dist + M, 0x3fffffff);
  fill(pre, pre + M, -1);
  dist[s] = 0;
  Q.push(make_pair(0, s));
  while (!Q.empty()) {
    int v = Q.top().second;
    Q.pop();
    if (v == t) return dist[v];
    for (int i = 0; i < (int)(edges[v].size()); i++) {
      int w = edges[v][i].first;
      int len = edges[v][i].second;
      if (dist[v] + len < dist[w]) {
        dist[w] = dist[v] + len;
        Q.push(make_pair(dist[w], w));
        pre[w] = v;
      }
    }
  }
  throw;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> L;
  for (int i = 0; i < (int)(n); i++) {
    int x, d, t, p;
    cin >> x >> d >> t >> p;
    ramps[i] = make_pair(make_pair(x - p, x + d), make_pair(t + p, i + 1));
  }
  sort(ramps, ramps + n);
  int ptr = 0;
  for (int i = 0; i < (int)(n); i++) {
    if (ramps[i].first.first >= 0) xs[ptr++] = ramps[i].first.first;
    if (ramps[i].first.second >= 0) xs[ptr++] = ramps[i].first.second;
  }
  xs[ptr++] = 0;
  xs[ptr++] = L;
  sort(xs, xs + ptr);
  M = unique(xs, xs + ptr) - xs;
  for (int i = 0; i < (int)(M); i++) {
    if (i - 1 >= 0) edges[i].push_back(make_pair(i - 1, xs[i] - xs[i - 1]));
    if (i + 1 < M) edges[i].push_back(make_pair(i + 1, xs[i + 1] - xs[i]));
  }
  for (int i = 0; i < (int)(n); i++) {
    int l = ramps[i].first.first;
    int r = ramps[i].first.second;
    int t = ramps[i].second.first;
    if (l < 0 || r < 0) continue;
    l = lower_bound(xs, xs + M, l) - xs;
    r = lower_bound(xs, xs + M, r) - xs;
    edges[l].push_back(make_pair(r, t));
  }
  int ret = dijkstra(0, M - 1);
  cout << ret << endl;
  int v = M - 1;
  ptr = 0;
  while (pre[v] != -1) {
    int w = pre[v];
    int x = lower_bound(ramps, ramps + n,
                        make_pair(make_pair(xs[w], xs[v]), make_pair(0, 0))) -
            ramps;
    if (ramps[x].first.first == xs[w] && ramps[x].first.second == xs[v] &&
        ramps[x].second.first < ramps[x].first.second - ramps[x].first.first) {
      used[ptr++] = ramps[x].second.second;
    }
    v = w;
  }
  cout << ptr << endl;
  while (ptr > 0) {
    cout << used[--ptr] << " ";
  }
  cout << endl;
  return 0;
}
