#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define pii pair<int, int>
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#ifdef CB
freopen("be2.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
#endif
int N, S, E;
cin >> N >> S >> E;
vector<vector<array<int, 3>>> v(E + 1);
for (int i = 0; i < N; i++) {
int s, e, c;
cin >> s >> e >> c;
v[s].push_back({e, c, i});
}
multimap<int, pii> m;
vector<pii> w;
m.insert({S, {0, -1}});
for (int i = S; i <= E; i++) {
if (m.lower_bound(i) == m.end()) {
cout << -1 << endl;
return 0;
}
auto [c, j] = m.lower_bound(i)->second;
for (auto a : v[i]) {
int k = w.size();
w.push_back({a[2], j});
auto it = m.insert({a[0] + 1, {c + a[1], k}});
while (it->second.first <= prev(it)->second.first) {
m.erase(prev(it));
}
while (next(it) != m.end() && next(it)->second.first <= it->second.first) {
it = m.erase(it);
}
}
}
if (m.lower_bound(E + 1) == m.end()) {
cout << -1 << endl;
return 0;
}
auto [c, j] = m.lower_bound(E + 1)->second;
cout << c << endl;
vector<int> ans;
while (j != -1) {
ans.push_back(w[j].first);
j = w[j].second;
}
sort(ans.begin(), ans.end());
cout << ans.size();
for (int i : ans) {
cout << ' ' << i + 1;
}
cout << endl;
return 0;
}