#include <bits/stdc++.h>
#include "books.h"
using namespace std;
//
// --- Sample implementation for the task books ---
//
// To compile this program with the sample grader, place:
// books.h books.cpp grader.cpp
// in a single folder and run:
// g++ books.cpp grader.cpp
// in this folder.
//
void solve(int n, int k, long long a, int s) {
vector<int> ans(n); for (int i = 0; i < n; i++) ans[i] = skim(i + 1);
multiset<pair<int, int>> val;
for (int i = 0; i < n; i++) val.insert({ans[i], i});
for (int i = 0; i < n; i++) {
val.erase(val.find({ans[i], i}));
for (int j = i + 1; j < n; j++) {
val.erase(val.find({ans[j], j}));
int sum = ans[i] + ans[j];
auto [guy, idx] = *val.lower_bound({a - sum, 0});
if (a <= sum + guy && sum + guy <= 2 * a) {
vector<int> resp;
resp.push_back(i + 1);
resp.push_back(j + 1);
resp.push_back(idx + 1);
answer(resp);
return;
}
val.insert({ans[j], j});
}
val.insert({ans[i], i});
}
impossible();
}