#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
map<int, int> mp;
int head[maxn], cnt, dis[maxn], vis[maxn], pre[maxn], w[maxn];
struct ed {
  int to, next, w, id;
} e[maxn * 3];
void ad(int x, int y, int w, int id) {
  e[cnt] = (ed){y, head[x], w, id};
  head[x] = cnt++;
}
struct ramp {
  int x, d, t, p;
} a[100005];
struct node {
  int id, d;
  friend bool operator<(node a, node b) { return a.d > b.d; }
};
void dijkstra(int t) {
  memset(dis, 0x3f, sizeof(dis));
  memset(vis, 0, sizeof(vis));
  priority_queue<node> q;
  pre[1] = -1;
  dis[1] = 0;
  q.push((node){1, 0});
  while (!q.empty()) {
    node a = q.top();
    q.pop();
    int u = a.id;
    if (vis[u]) continue;
    if (u == t) break;
    vis[u] = 1;
    for (int k = head[u]; k != -1; k = e[k].next) {
      int v = e[k].to;
      if (dis[v] > dis[u] + e[k].w) {
        dis[v] = dis[u] + e[k].w;
        pre[v] = u;
        w[v] = e[k].id;
        q.push((node){v, dis[v]});
      }
    }
  }
}
int k = 0;
void print(int x) {
  if (pre[x] == -1)
    printf("%d\n", k);
  else {
    if (w[x]) k++;
    print(pre[x]);
    if (w[x]) printf("%d ", w[x]);
  }
}
int main() {
  memset(head, -1, sizeof(head));
  int n, L;
  scanf("%d%d", &n, &L);
  mp[0] = mp[L] = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d%d", &a[i].x, &a[i].d, &a[i].t, &a[i].p);
    if (a[i].x - a[i].p >= 0) mp[a[i].x - a[i].p] = 0;
    mp[a[i].x + a[i].d] = 1;
  }
  int id = 1;
  for (map<int, int>::iterator it = mp.begin(), itt = mp.begin();
       it != mp.end(); it++) {
    if (id > 1) {
      ad(id - 1, id, it->first - itt->first, 0);
      ad(id, id - 1, it->first - itt->first, 0);
      itt++;
    }
    it->second = id++;
  }
  for (int i = 1; i <= n; i++) {
    if (a[i].x - a[i].p >= 0 && a[i].p + a[i].d > a[i].t)
      ad(mp[a[i].x - a[i].p], mp[a[i].x + a[i].d], a[i].t + a[i].p, i);
  }
  dijkstra(mp[L]);
  printf("%d\n", dis[mp[L]]);
  print(mp[L]);
  return 0;
}
