#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 20;
map<int, int> mp;
int n, l;
vector<int> ar;
vector<pair<pair<int, int>, int>> graph[maxn];
vector<pair<pair<int, int>, pair<int, int>>> q;
long long dis[maxn];
set<pair<long long, int>> dij;
pair<int, int> tmp, dad[maxn];
bool mark[maxn];
void print(int x, int td) {
  if (x != 0) {
    if (dad[x].second != 0) td++;
    print(dad[x].first, td);
    if (dad[x].second != 0) cout << dad[x].second << " ";
  } else
    cout << td << endl;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  fill(dis, dis + maxn, 1e15);
  cin >> n >> l;
  mp[0] = 1, ar.push_back(0);
  mp[l] = 1, ar.push_back(l);
  for (int i = 0, x, d, t, p; i < n; i++) {
    cin >> x >> d >> t >> p;
    if (x - p >= 0 && x + d <= l) {
      q.push_back({{x - p, x + d}, {t + p, i + 1}});
      if (!mp.count(x - p)) mp[x - p] = 1, ar.push_back(x - p);
      if (!mp.count(x + d)) mp[x + d] = 1, ar.push_back(x + d);
    }
  }
  sort(ar.begin(), ar.end());
  for (int i = 0; i < ar.size(); i++) {
    mp[ar[i]] = i;
    if (i != ar.size() - 1) graph[i].push_back({{i + 1, ar[i + 1] - ar[i]}, 0});
    if (i != 0) graph[i].push_back({{i - 1, ar[i] - ar[i - 1]}, 0});
  }
  for (auto x : q)
    graph[mp[x.first.first]].push_back(
        {{mp[x.first.second], x.second.first}, x.second.second});
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      qp;
  qp.push({0, 0});
  dis[0] = 0;
  while (!qp.empty()) {
    tmp = qp.top();
    qp.pop();
    if (mark[tmp.second]) continue;
    mark[tmp.second] = 1;
    for (auto u : graph[tmp.second])
      if (dis[u.first.first] > dis[tmp.second] + u.first.second) {
        dis[u.first.first] = dis[tmp.second] + u.first.second;
        qp.push({dis[u.first.first], u.first.first});
        dad[u.first.first] = {tmp.second, u.second};
      }
  }
  cout << dis[mp[l]] << endl;
  print(mp[l], 0);
  cout << endl;
}
