#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void Solve() {
  int n, k;
  scanf("%d%d", &n, &k);
  vector<pair<pair<int, int>, int>> s(n);
  for (int i = 0; i < n; i++)
    scanf("%d%d", &s[i].first.first, &s[i].first.second), s[i].second = i;
  ;
  sort(s.begin(), s.end());
  set<pair<int, int>> rs;
  for (int i = 0; i < k - 1; i++) rs.insert({s[i].first.second, i});
  pair<int, int> best(0, k - 1);
  for (int i = k - 1; i < n; i++) {
    rs.insert({s[i].first.second, i});
    best = max(best, {max(0, rs.begin()->first - s[i].first.first + 1), i});
    rs.erase(rs.begin());
  }
  printf("%d\n", best.first);
  rs.clear();
  for (int i = 0; i < k - 1; i++) rs.insert({s[i].first.second, i});
  for (int i = k - 1; i < n; i++) {
    rs.insert({s[i].first.second, i});
    if (i == best.second) break;
    rs.erase(rs.begin());
  }
  for (auto x : rs) printf("%d ", s[x.second].second + 1);
}
int main() {
  Solve();
  return 0;
}
