// https://szkopul.edu.pl/problemset/problem/KkN5UonnNGIG3AuMqoI6xr62/site/?key=statement
// Prawnicy
#include <bits/stdc++.h>
using namespace std;
#define int long long
constexpr int sizik = 1000 * 1001, MAX_ANS = 1e9 + 1;
#define ar std::array
#define pr std::pair
#define vec std::vector
typedef vec<vec<int>> _kra;
typedef ar<int, 2> Duo;
int d(const Duo& a) {
return a[1] - a[0] + 1;
}
int n, k;
std::vector<Duo> v, v2;
std::set<int> ss;
std::vector<int> ans;
std::map<int, int> dod;
bool check(int s) {
std::priority_queue<int, std::vector<int>, std::greater<int>> q;
int curr = 0;
for (const auto& a : ss) {
int x = s + a - 1;
while (!q.empty() && q.top() < x) {
q.pop();
}
for (; curr < (int)v.size(); curr++) {
if (v[curr][0] > a) {
break;
}
if (v[curr][1] >= x) {
q.push(v[curr][1]);
}
}
if (q.size() >= k) {
dod[s] = a;
return true;
}
}
return false;
}
void get_ans(int s) {
int a = dod[s];
for (int i = 0; i < (int)v2.size() && (int)ans.size() < k; i++) {
const auto& [p, k] = v2[i];
if (p <= a && k >= s + a - 1) {
ans.push_back(i + 1);
}
}
}
void solve() {
std::cin >> n >> k;
v.resize(n);
for (auto& [a, b] : v) {
std::cin >> a >> b;
ss.insert(a);
ss.insert(b);
v2.push_back({a, b});
}
std::sort(v.begin(), v.end(), [](const Duo& a, const Duo& b) { return a[0] < b[0]; });
int l = 1, p = MAX_ANS;
while (l < p) {
int s = (l + p + 1) / 2;
if (check(s)) {
l = s;
} else {
p = s - 1;
}
}
std::cout << l - 1 << '\n';
get_ans(l);
for (const auto& a : ans) {
std::cout << a << ' ';
}
std::cout << '\n';
}
int32_t main() {
std::ios_base::sync_with_stdio(0);
std::cin.tie(0);
std::cout.tie(0);
int t = 1;
// std::cin >> t;
for (; t > 0; t--) {
solve();
}
return 0;
}