#include <bits/stdc++.h>
using namespace std;
int uu[700010], vv[700010], nxt[700010], tt[700010], h[300600], e;
int d[300600], vis[300600], pre[300600];
int lisan[300600], cnt;
int id[700010];
int getId(int x) { return lower_bound(lisan, lisan + cnt, x) - lisan; }
void add(int u, int v, int t) {
  uu[e] = u, vv[e] = v, tt[e] = t, nxt[e] = h[u], h[u] = e++;
}
struct Ramp {
  int x, d, t, p;
} rp[300600];
int q[700010], head, tail;
int spfa() {
  memset(d, -1, sizeof(d));
  memset(vis, 0, sizeof(vis));
  d[0] = 0;
  head = tail = 0;
  q[tail++] = 0;
  int u, v;
  while (head != tail) {
    u = q[head++];
    if (head >= 700010) head = 0;
    vis[u] = 0;
    for (int i = h[u]; i + 1; i = nxt[i]) {
      v = vv[i];
      if (d[v] == -1 || d[v] > d[u] + tt[i]) {
        d[v] = d[u] + tt[i];
        pre[v] = i;
        if (!vis[v]) {
          vis[v] = 1;
          if (d[v] > d[q[head]]) {
            q[tail++] = v;
            if (tail >= 700010) tail = 0;
          } else {
            --head;
            if (head < 0) head = 700010 - 1;
            q[head] = v;
          }
        }
      }
    }
  }
  return d[cnt - 1];
}
int ans[300600];
void getAns() {
  int c = 0, u = cnt - 1, v;
  while (u != 0) {
    v = pre[u];
    if (id[v] != -1) ans[c++] = id[v];
    u = uu[v];
  }
  cout << c << endl;
  for (int i = c - 1; i >= 0; --i) {
    printf("%d%c", ans[i], i ? ' ' : '\n');
  }
}
int main() {
  int n, m, L;
  scanf("%d%d", &n, &L);
  cnt = 0;
  lisan[cnt++] = 0;
  lisan[cnt++] = L;
  for (int i = 0; i < n; ++i) {
    scanf("%d%d%d%d", &rp[i].x, &rp[i].d, &rp[i].t, &rp[i].p);
    if (rp[i].x - rp[i].p >= 0) lisan[cnt++] = rp[i].x - rp[i].p;
    lisan[cnt++] = rp[i].x + rp[i].d;
    lisan[cnt++] = rp[i].x;
  }
  sort(lisan, lisan + cnt);
  cnt = unique(lisan, lisan + cnt) - lisan;
  memset(h, -1, sizeof(h));
  e = 0;
  memset(id, -1, sizeof(id));
  for (int i = 1; i < cnt; ++i) {
    add(i - 1, i, lisan[i] - lisan[i - 1]);
    add(i, i - 1, lisan[i] - lisan[i - 1]);
  }
  int l, r;
  for (int i = 0; i < n; ++i) {
    if (rp[i].x - rp[i].p >= 0) {
      l = getId(rp[i].x - rp[i].p);
      r = getId(rp[i].x + rp[i].d);
      add(l, r, rp[i].t + rp[i].p);
      id[e - 1] = i + 1;
    }
  }
  printf("%d\n", spfa());
  getAns();
}
