#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
const int inf = 0x3f3f3f3f;
double pi = 3.1415926535898;
int tmp, cnt, n, m, head[maxn], dis[maxn], disa[maxn], color[maxn], len,
    pre[maxn], tt, ans[maxn];
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    q;
struct st {
  int s, t, w;
} f[maxn];
struct stt {
  int next, to, w, id, u;
} e[maxn];
void add(int u, int v, int w, int id) {
  e[++tmp].next = head[u];
  e[tmp].u = u;
  e[tmp].id = id;
  e[tmp].to = v;
  e[tmp].w = w;
  head[u] = tmp;
}
void Dijkstra() {
  memset(disa, 0x3f, sizeof(disa));
  disa[1] = 0;
  pre[1] = -1;
  q.push({0, 1});
  while (!q.empty()) {
    int x = q.top().second;
    q.pop();
    if (color[x]) continue;
    color[x] = 1;
    for (int i = head[x]; i != -1; i = e[i].next) {
      int v = e[i].to;
      if (disa[x] + e[i].w < disa[v]) {
        disa[v] = disa[x] + e[i].w;
        pre[v] = i;
        q.push({disa[v], v});
      }
    }
  }
  for (int i = pre[cnt]; i != -1; i = pre[e[i].u]) {
    if (e[i].id != -1) ans[++tt] = e[i].id;
  }
}
int main() {
  scanf("%d %d", &n, &m);
  dis[++cnt] = 0;
  dis[++cnt] = m;
  memset(head, -1, sizeof(head));
  for (int i = 1; i <= n; ++i) {
    int x, d, t, p;
    scanf("%d%d%d%d", &x, &d, &t, &p);
    f[i].s = x - p;
    f[i].t = x + d;
    f[i].w = t + p;
    if (x - p < 0 || x + d > m) continue;
    dis[++cnt] = x - p;
    dis[++cnt] = x + d;
  }
  sort(dis + 1, dis + cnt + 1);
  cnt = unique(dis + 1, dis + cnt + 1) - dis - 1;
  for (int i = 1; i <= n; ++i) {
    if (f[i].s < 0 || f[i].t > m) continue;
    int x = lower_bound(dis + 1, dis + cnt + 1, f[i].s) - dis;
    int y = lower_bound(dis + 1, dis + cnt + 1, f[i].t) - dis;
    add(x, y, f[i].w, i);
  }
  for (int i = 2; i <= cnt; ++i) {
    int x = i - 1, y = i, k = dis[y] - dis[x];
    add(x, y, k, -1);
    add(y, x, k, -1);
  }
  Dijkstra();
  printf("%d\n", disa[cnt]);
  printf("%d\n", tt);
  for (int i = tt; i >= 1; --i) {
    printf("%d ", ans[i]);
  }
  return 0;
}
