# cf 教育场4 ，区间交集个数

#include <cstdio>
#include <string>
#include <cstring>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <iostream>

using namespace std;
#define maxn 2000005
#define MOD 1000000007
#define mem(a) memset(a , 0 , sizeof(a))
#define LL __int64

LL n , k;

struct node
{
int val;
int flag;
/*friend bool cmp(node a , node b)
{
return a.val < b.val;
}*/
friend bool operator <(node a , node b)
{
if(a.val == b.val)
return a.flag < b.flag;
return a.val < b.val;
}
}arr[maxn];

struct pointe
{
int left;
int right;
int flag;
}res[maxn] ;

int main()
{
while(scanf("%I64d %I64d" , &n , &k) != EOF )
{
int tmp;
int num = 2 * n;
for(int i = 0 ; i < num ; i ++)
{
scanf("%d" , &tmp);
if(i % 2) arr[i].flag = 1;
else arr[i].flag = 0;
arr[i].val = tmp;
}
sort(arr , arr + num );
int ans = 0;
int pos = 1;
int left = 0;
for(int i = 0 ; i < num ; i ++)
{
if(arr[i].flag) ans--;
else ans++;
if(ans >= k && !left)
{
res[pos].left = arr[i].val;
left = 1;
}
else if(ans < k && left)
{
left = 0;
res[pos].flag = 0;
res[pos++].right = arr[i].val;
}
}
int pos2 = pos;
for(int i = 1 ; i < pos - 1 ; i ++)
{
if(res[i].right == res[i+1].left) res[i].flag = 1 , pos -- ;
}
printf("%d\n" , pos - 1);
res[0].flag = 0;
for(int i = 1 ; i < pos2 ; i ++)
{
//cout << res[i].flag<<endl;
if(!res[i].flag && !res[i-1].flag )
printf("%d %d\n" , res[i].left , res[i].right);
else if(!res[i].flag && res[i-1].flag)
{
printf("%d\n" , res[i].right);
}
else if(res[i].flag && res[i-1].flag )
continue;
else if(res[i].flag && !res[i-1].flag  )
printf("%d " , res[i].left);
}
}
return 0;
}

06-16 100

07-29 43
11-02 94
09-28 45万+
01-22 1万+
10-26 110
02-23 705
06-05 9811
12-31
06-10 168
06-10 167