#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9;
const long long MOD = 1000000007;
struct node {
  long long x, d, t, p, nm, kek;
  node(long long x1, long long d1, long long t1, long long p1) {
    x = x1;
    d = d1;
    t = t1;
    p = p1;
  }
  node() { x = d = t = p = 0; }
};
vector<node> a;
bool comp(node a, node b) { return a.x < b.x; }
struct vrt {
  int a, num, d;
  vrt(int x, int i, int di) {
    a = x;
    num = i;
    d = di;
  }
  vrt() { a = num = d = 0; }
};
map<int, int> m;
vector<int> d, p, u;
vector<int> tr;
vector<vector<vrt> > g;
int main() {
  ios_base::sync_with_stdio(0);
  int n, l;
  cin >> n >> l;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    int x, d, t, p;
    cin >> x >> d >> t >> p;
    a[i] = node(x, d, t, p);
    a[i].nm = i + 1;
  }
  sort(a.begin(), a.end(), comp);
  m[0] = 0;
  m[l] = 0;
  for (int i = 0; i < n; i++) {
    int x1 = a[i].x - a[i].p;
    int x2 = a[i].x + a[i].d;
    if (x1 >= 0) m[x1] = 0;
    if (x2 <= l) m[x2] = 0;
  }
  map<int, int>::iterator it;
  int cnt = 0;
  for (it = m.begin(); it != m.end(); it++) it->second = cnt++;
  g.resize(cnt);
  d.resize(cnt);
  p.resize(cnt);
  for (int i = 0; i < n; i++) {
    int x1 = a[i].x - a[i].p;
    int x2 = a[i].x + a[i].d;
    if (x1 < 0 || x2 > l) continue;
    g[m[x1]].push_back(vrt(m[x2], a[i].nm, a[i].t + a[i].p));
  }
  map<int, int>::iterator itp = m.begin();
  for (it = ++m.begin(); it != m.end(); it++) {
    if (it != m.begin()) {
      int x1 = it->second;
      int x2 = itp->second;
      int y1 = it->first;
      int y2 = itp->first;
      g[x1].push_back(vrt(x2, -1, y1 - y2));
      g[x2].push_back(vrt(x1, -1, y1 - y2));
      itp = it;
    }
  }
  for (int i = 0; i < cnt; i++) d[i] = INF;
  d[0] = 0;
  priority_queue<pair<long long, int> > q;
  q.push(make_pair(0, 0));
  tr.resize(cnt, -1);
  while (!q.empty()) {
    pair<long long, int> tmp = q.top();
    q.pop();
    long long dist = -tmp.first;
    int num = tmp.second;
    if (dist > d[num]) continue;
    for (int i = 0; i < g[num].size(); i++) {
      int to = g[num][i].a;
      long long dist2 = g[num][i].d;
      if (dist + dist2 < d[to]) {
        d[to] = dist + dist2;
        p[to] = num;
        tr[to] = g[num][i].num;
        q.push(make_pair(-d[to], to));
      }
    }
  }
  cout << d[cnt - 1] << endl;
  vector<int> s;
  int t = cnt - 1;
  while (t != 0) {
    int nm = tr[t];
    if (nm != -1) s.push_back(nm);
    t = p[t];
  }
  reverse(s.begin(), s.end());
  cout << s.size() << endl;
  for (int i = 0; i < s.size(); i++) cout << s[i] << " ";
  cout << endl;
  return 0;
}
