#include <bits/stdc++.h>
using namespace std;
bool ord(pair<int, pair<int, int> > a, pair<int, pair<int, int> > b) {
  return (a.second.first < b.second.first);
}
bool ord1(pair<int, pair<int, int> > a, pair<int, pair<int, int> > b) {
  return (a.second.second > b.second.second);
}
int main() {
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<pair<int, pair<int, int> > > p(n);
  int a, b;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    p[i] = {i + 1, {a, b}};
  }
  sort(p.begin(), p.end(), ord);
  priority_queue<int, vector<int>, greater<int> > pq;
  for (int i = 0; i < k - 1; i++) {
    pq.push(p[i].second.second);
  }
  int bes = k - 1, ma = 0, dist;
  for (int i = k - 1; i < n; i++) {
    pq.push(p[i].second.second);
    dist = pq.top() - p[i].second.first + 1;
    if (dist > ma) bes = i, ma = dist;
    pq.pop();
  }
  cout << ma << endl;
  vector<int> resp(k, 1);
  if (bes >= 0 && bes < n) resp[0] = p[bes].first;
  if (bes > 0 && bes <= n) sort(p.begin(), p.begin() + bes, ord1);
  for (int i = 0; i < k - 1; i++) resp[i + 1] = p[i].first;
  sort(resp.begin(), resp.end());
  for (int i = 0; i < k; i++) cout << resp[i] << " ";
  cout << endl;
  return 0;
}
