#include <bits/stdc++.h>
using namespace std;
void boost() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const int N = 1e6;
const long long inf = 1e9 + 7;
const long double PI = acos(-1);
long long bin_pow(long long x, long long y) {
  long long res = 1, base = x;
  while (y) {
    if (y & 1) {
      res *= base;
      res %= inf;
    }
    base *= base;
    base %= inf;
    y /= 2;
  }
  return res;
}
multiset<long long> q;
pair<pair<long long, long long>, int> a[N];
int n, k;
long long mx = 0, mn = -inf, ansr;
int main() {
  boost();
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].first.first >> a[i].first.second;
    a[i].second = i;
  }
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= k; i++) {
    q.insert(a[i].first.second);
  }
  mx = max((long long)0, *q.begin() - a[k].first.first + 1);
  int l = 1, r = k;
  ansr = k;
  while (r < n) {
    q.erase(q.begin());
    l++;
    r++;
    q.insert(a[r].first.second);
    long long cur = max((long long)0, *q.begin() - a[r].first.first + 1);
    if (cur > mx) {
      mn = *q.begin();
      ansr = r;
      mx = cur;
    }
  }
  cout << mx << "\n";
  for (int i = 1; i <= ansr; i++) {
    if (a[i].first.second >= mn) {
      cout << a[i].second << " ";
    }
  }
}
