#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int main() {
  int n, L;
  cin >> n >> L;
  if (n == 0) {
    cout << L << "\n" << 0;
    return 0;
  }
  map<int, vector<pair<pair<int, int>, int> > > graph;
  for (int i = 0; i < n; i++) {
    int x, dist, time, pos;
    cin >> x >> dist >> time >> pos;
    if (x - pos >= 0) {
      if (!graph.count(x - pos)) {
        graph[x - pos] = {{{x + dist, time + pos}, i + 1}};
      } else {
        graph.at(x - pos).push_back({{x + dist, time + pos}, i + 1});
      }
    }
    graph[x + dist];
  }
  if (graph.begin()->first != 0) {
    graph[0];
  }
  if (graph.rbegin()->first != L) {
    graph[L];
  }
  auto it1 = graph.begin();
  it1++;
  while (it1 != graph.end()) {
    auto i = it1;
    i--;
    (it1->second).push_back({{i->first, (it1->first) - (i->first)}, -1});
    it1++;
  }
  it1 = graph.begin();
  auto it2 = graph.end();
  it2--;
  while (it1 != it2) {
    auto i = it1;
    i++;
    (it1->second).push_back({{i->first, (i->first) - (it1->first)}, -1});
    it1++;
  }
  map<int, pair<int, int> > prev;
  prev[0] = {-1, -1};
  set<pair<int, int> > s_distances;
  s_distances.insert({0, 0});
  map<int, int> m_distances;
  m_distances[0] = 0;
  auto it = graph.begin();
  it++;
  while (it != graph.end()) {
    s_distances.insert({INF, it->first});
    m_distances[it->first] = INF;
    it++;
  }
  while (!s_distances.empty()) {
    auto v = *s_distances.begin();
    s_distances.erase(s_distances.begin());
    if (v.second == L) {
      cout << m_distances[v.second] << "\n";
      vector<int> answer;
      int a = L;
      while (prev[a].first != -1) {
        if (prev[a].second != -1) {
          answer.push_back(prev[a].second);
        }
        a = prev[a].first;
      }
      cout << answer.size() << "\n";
      for (int i = answer.size() - 1; i >= 0; i--) {
        cout << answer[i] << " ";
      }
      return 0;
    }
    for (auto& i : graph[v.second]) {
      if (v.first + i.first.second < m_distances[i.first.first]) {
        s_distances.erase({m_distances[i.first.first], i.first.first});
        m_distances[i.first.first] = v.first + i.first.second;
        s_distances.insert({v.first + i.first.second, i.first.first});
        prev[i.first.first] = {v.second, i.second};
      }
    }
  }
  return 0;
}
