#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
vector<int> mg, ans;
vector<pair<pair<int, int>, int> > e;
vector<pair<pair<int, int>, pair<int, int> > > f, g;
int x[N], d[N], t[N], p[N], answer = 0, tmp, dis[N], par[N], vz[N];
set<pair<int, int> > s;
vector<pair<int, int> > nei[N];
map<int, int> mp;
map<pair<pair<int, int>, int>, int> vis, q;
void dij() {
  s.insert({0, 1});
  while (s.size()) {
    int v = s.begin()->second;
    s.erase(s.begin());
    for (auto u : nei[v]) {
      if (dis[v] + u.second < dis[u.first]) {
        s.erase({dis[u.first], u.first});
        dis[u.first] = dis[v] + u.second;
        s.insert({dis[u.first], u.first});
        par[u.first] = v;
        vz[u.first] = u.second;
      }
    }
  }
  cout << dis[tmp] << endl;
}
int main() {
  int l, n;
  cin >> n >> l;
  mg.push_back(0);
  mg.push_back(l);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> d[i] >> t[i] >> p[i];
    g.push_back({{x[i], d[i]}, {t[i], p[i]}});
    if (x[i] >= p[i]) {
      f.push_back({{x[i], d[i]}, {t[i], p[i]}});
      mg.push_back(x[i] - p[i]), mg.push_back(x[i] + d[i]);
    }
  }
  sort(mg.begin(), mg.end());
  mg.resize(unique(mg.begin(), mg.end()) - mg.begin());
  for (int i : mg) tmp++, mp[i] = tmp;
  for (int i = 0; i < mg.size() - 1; i++) {
    int w = mg[i + 1] - mg[i], po = mp[mg[i]], po1 = mp[mg[i + 1]];
    nei[po].push_back({po1, w});
    nei[po1].push_back({po, w});
  }
  for (auto i : f) {
    if (i.first.first >= i.second.second) {
      int po = mp[i.first.first - i.second.second],
          po1 = mp[i.first.first + i.first.second],
          w = i.second.first + i.second.second;
      nei[po].push_back({po1, w});
      vis[{{po, po1}, w}] = 1;
    }
  }
  memset(dis, 63, sizeof dis);
  dis[1] = 0;
  dij();
  int sum = 1;
  for (auto i : g) {
    q[{{mp[i.first.first - i.second.second],
        mp[i.first.first + i.first.second]},
       i.second.second + i.second.first}] = sum;
    sum++;
  }
  int k = tmp;
  par[1] = 0;
  while (par[k] != 0) {
    if (vis[{{par[k], k}, vz[k]}]) {
      ans.push_back(q[{{par[k], k}, vz[k]}]);
      answer++;
    }
    k = par[k];
  }
  cout << answer << endl;
  reverse(ans.begin(), ans.end());
  for (int i : ans) cout << i << ' ';
}
