#include <bits/stdc++.h>
using namespace std;
pair<int, pair<int, int> > ps[300100];
int n, k, l[300100], r[300100];
set<pair<int, int> > second, s1;
int main() {
  scanf("%d", &n), scanf("%d", &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &ps[i].first), scanf("%d", &ps[i].second.first);
    ps[i].second.second = i;
  }
  sort(ps, ps + n);
  for (int i = 0; i < k - 1; i++) {
    int loc = ps[i].second.second;
    second.insert(make_pair(ps[i].second.first, loc));
    s1.insert(make_pair(ps[i].second.first, loc));
  }
  int mx = 0, loc = k - 1;
  for (int i = k - 1; i < n; i++) {
    int l1 = ps[i].second.second;
    int ele = 1000000007 + 100;
    if (second.begin() != second.end()) ele = (*second.begin()).first;
    int pre = min(ele, ps[i].second.first) - ps[i].first + 1;
    if (pre > mx) mx = pre, loc = i;
    if (ps[i].second.first > ele) {
      second.erase(second.begin());
      second.insert(make_pair(ps[i].second.first, l1));
    }
  }
  printf("%d\n", mx);
  for (int i = k - 1; i < loc; i++) {
    int l1 = ps[i].second.second;
    int ele = (*s1.begin()).first;
    if (ps[i].second.first > ele) {
      s1.erase(s1.begin());
      s1.insert(make_pair(ps[i].second.first, l1));
    }
  }
  for (set<pair<int, int> >::iterator it = s1.begin(); it != s1.end(); it++) {
    printf("%d ", (*it).second + 1);
  }
  printf("%d ", ps[loc].second.second + 1);
  return 0;
}
