#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
typedef long long ll;
ll n,k,ans,l;
priority_queue<ll>s;//优先队列
struct item
{
ll x,y,pos;
}a[333333];
bool cmp(item a, item b)
{
return a.x<b.x;
}
int main()
{
//ios::sync_with_stdio(false);
cin>>n>>k;
for(ll i=1;i<=n;i++)
{
scanf("%lld %lld",&a[i].x,&a[i].y);
a[i].pos=i;
}
sort(a+1,a+n+1,cmp);//先按左边排序
for(ll i=1;i<=n;i++)
{
if(s.size()<k)
s.push(-a[i].y);
else if(-s.top()<a[i].y)
s.pop(),s.push(-a[i].y);
if(ans<-s.top()-a[i].x+1&&s.size()==k)//定时更新右边
ans=-s.top()-a[i].x+1,
l=a[i].x;
}
cout<<ans<<endl;
if(ans==0)
{
for(ll i=1;i<=k;i++)
printf("%lld ",i);
return 0;
}
for(ll i=1;i<=n&&k;i++)
if(a[i].x<=l&&l+ans-1<=a[i].y)
printf("%lld ",a[i].pos),k--;
}