#include <bits/stdc++.h>
using namespace std;
struct ramp {
  int x, d, t, p;
  int id;
} ram[100011];
int par[200010];
int par_id[200010];
int vis[200010];
struct node {
  int des;
  int len;
  int id;
} temp, f, t;
class comp {
 public:
  bool operator()(const node &a, const node &b) { return a.len > b.len; }
};
priority_queue<node, vector<node>, comp> PQ;
vector<node> adj[200010];
set<int> s;
map<int, int> mp;
vector<int> pos;
int dist[200010];
int main() {
  int i, j, k, n, L, u, v;
  scanf("%d %d", &n, &L);
  s.insert(0);
  s.insert(L);
  for (i = 0; i < 200010; i++) {
    dist[i] = 1 << 30;
  }
  for (i = 0; i < n; i++) {
    scanf("%d %d %d %d", &ram[i].x, &ram[i].d, &ram[i].t, &ram[i].p);
    if ((ram[i].x - ram[i].p) < 0) continue;
    s.insert(ram[i].x - ram[i].p);
    s.insert(ram[i].x + ram[i].d);
  }
  int I = 0;
  for (set<int>::iterator it = s.begin(); it != s.end(); it++) {
    pos.push_back(*it);
    mp[*it] = I++;
  }
  for (i = 0; i < pos.size() - 1; i++) {
    temp.id = 0;
    temp.len = pos[i + 1] - pos[i];
    temp.des = i + 1;
    adj[i].push_back(temp);
    temp.des = i;
    adj[i + 1].push_back(temp);
  }
  for (i = 0; i < n; i++) {
    if ((ram[i].x - ram[i].p) < 0) continue;
    u = mp[ram[i].x - ram[i].p];
    temp.des = mp[ram[i].x + ram[i].d];
    temp.len = ram[i].t + ram[i].p;
    temp.id = i + 1;
    adj[u].push_back(temp);
  }
  temp.des = 0;
  temp.len = 0;
  PQ.push(temp);
  int ans = -1;
  dist[0] = 0;
  while (!PQ.empty()) {
    f = PQ.top();
    PQ.pop();
    u = f.des;
    if (vis[u]) continue;
    if (u == (I - 1)) {
      ans = dist[I - 1];
      break;
    }
    vis[u] = 1;
    for (i = 0; i < adj[u].size(); i++) {
      t = adj[u][i];
      v = t.des;
      if ((dist[u] + t.len) < dist[v]) {
        dist[v] = dist[u] + t.len;
        t.len = dist[u] + t.len;
        par[v] = u;
        par_id[v] = t.id;
        PQ.push(t);
      }
    }
  }
  printf("%d\n", ans);
  vector<int> ANS;
  int now = I - 1;
  while (now != 0) {
    if (par_id[now]) ANS.push_back(par_id[now]);
    now = par[now];
  }
  reverse(ANS.begin(), ANS.end());
  printf("%d\n", ANS.size());
  for (i = 0; i < ANS.size(); i++) {
    printf("%d\n", ANS[i]);
  }
  return 0;
}
