#include <bits/stdc++.h>
using namespace std;
void ga(int N, int *A) {
  for (int i(0); i < N; i++) scanf("%d", A + i);
}
long long cn[(2000005)], e[(2000005)], g[(2000000)], p[(2000000)], V[(2000000)],
    O, P[(2000005)], F[(2000000)], R[(2000005)];
void dj(int f) {
  (memset(cn, -1, sizeof(cn))), cn[f] = 0, P[f] = -1;
  set<pair<long long, long long> > q = {{0, f}};
  while (!q.empty()) {
    long long u((*q.begin()).second), v((*q.begin()).first);
    q.erase((*q.begin()));
    for (int d(e[u]); ~d; d = p[d])
      if (!~cn[g[d]])
        q.insert({cn[g[d]] = V[d] + v, g[d]}), P[g[d]] = u, R[g[d]] = F[d];
      else if (cn[g[d]] > V[d] + v)
        q.erase({cn[g[d]], g[d]}), q.insert({cn[g[d]] = V[d] + v, g[d]}),
            P[g[d]] = u, R[g[d]] = F[d];
  }
}
int N, L, I, a, b, c, d, X[(2000005)], T[(2000005)], D[(2000005)], J,
    W[(2000005)];
pair<int, int> o[(2000005)];
vector<int> G;
void rc(int u, int w) {
  if (o[u].second > 1 && w) G.push_back(u);
  if (~P[u]) rc(P[u], R[u]);
}
int main(void) {
  ((memset(e, -1, sizeof(e))), O = 0);
  scanf("%d%d", &N, &L);
  X[I] = 0, T[I] = 0, D[I] = 0, o[J++] = {0, I++};
  X[I] = L, T[I] = 0, D[I] = L, o[J++] = {L, I++};
  for (int i(0); i < N; i++) {
    scanf("%d%d%d%d", &a, &b, &c, &d), b += a, a -= d, c += d;
    if (a < 0) continue;
    W[I] = i + 1, X[I] = a, T[I] = c, D[I] = b, o[J++] = {a, I++};
  }
  sort(o, o + J);
  for (int i(0); i < I - 1; i++) {
    (V[O] = o[i + 1].first - o[i].first, p[O] = e[i], g[O] = i + 1, F[O] = 0,
     e[i] = O++);
    if (i)
      (V[O] = o[i].first - o[i - 1].first, p[O] = e[i], g[O] = i - 1, F[O] = 0,
       e[i] = O++);
    pair<int, int> z = {D[o[i].second], -int(1e9 + 1)};
    a = lower_bound(o, o + I, z) - o;
    (V[O] = T[o[i].second] + o[a].first - D[o[i].second], p[O] = e[i], g[O] = a,
     F[O] = 1, e[i] = O++);
    --a;
    (V[O] = T[o[i].second] + D[o[i].second] - o[a].first, p[O] = e[i], g[O] = a,
     F[O] = 1, e[i] = O++);
  }
  dj(0);
  for (int i(0); i < I; i++)
    if (o[i].second == 1) a = i;
  printf("%lld\n", cn[a]), rc(a, 1);
  printf("%lu\n", G.size()), reverse(G.begin(), G.end());
  for (auto &h : G) printf("%d ", W[o[h].second]);
  puts("");
  return 0;
}
