You are given *n* segments on the coordinate axis Ox and the number *k*. The point is satisfied if it belongs to at least *k* segments. Find the smallest (by the number of segments) set of segments on the coordinate axis Ox which contains all satisfied points and no others.
The first line contains two integers *n* and *k* (1 ≤ *k* ≤ *n* ≤ 10<sup class="upper-index">6</sup>) — the number of segments and the value of *k*.

The next *n* lines contain two integers *l*<sub class="lower-index">*i*</sub>, *r*<sub class="lower-index">*i*</sub> ( - 10<sup class="upper-index">9</sup> ≤ *l*<sub class="lower-index">*i*</sub> ≤ *r*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">9</sup>) each — the endpoints of the *i*-th segment. The segments can degenerate and intersect each other. The segments are given in arbitrary order.
none
3 2
0 5
-3 2
3 8
2
0 2
3 5
3 2
0 5
-3 3
3 8
1
0 5
1 1
-1 1
1
-1 1
10 2
27 96
-22 45
-68 26
46 69
-91 86
12 73
-89 76
-11 33
17 47
-57 78
1
-89 86
10 1
3 60
-73 -37
59 69
-56 1
-84 -24
-14 46
-65 -23
-66 -57
-87 -80
-21 20
1
-87 69
10 10
-92 87
-100 -67
-88 80
-82 -59
-72 81
-50 30
30 77
65 92
-76 -60
-29 -15
0
1 1
-941727901 756748222
1
-941727901 756748222
1 1
-990637865 387517231
1
-990637865 387517231
1 1
-870080964 571991746
1
-870080964 571991746
10 8
-749560329 759073394
-186423470 816422576
-674251064 742056817
-342947007 954589677
-306243234 999298121
-448636479 409818446
-885248428 624359061
-936960294 754851875
-781500924 984124751
-342740564 618223559
1
-342740564 624359061
10 1
-260424665 -168566709
299109864 663179811
769984405 942516913
-998905510 -707148023
-167958021 60599275
658861231 718845364
79407402 279078536
13652788 79756488
-676213666 -339118351
-349156760 -258185154
5
-998905510 -707148023
-676213666 -168566709
-167958021 279078536
299109864 718845364
769984405 942516913
10 8
-278661264 757623461
-751226975 996393413
-721476675 863607399
-228431002 643113689
-209293138 701503607
-433870703 932866969
-385182911 667745533
-661057075 783312740
-617789923 657076219
-890369225 990071765
1
-278661264 667745533
4 2
2 2
2 2
2 3
3 3
2
2 2
3 3
2 2
-3 1
-4 -1
1
-3 -1
1 1
2 2
1
2 2
2 1
0 2
-1 0
1
-1 2
2 2
-1000000000 1000000000
-1000000000 100
1
-1000000000 100
#I = lambda: [int(i) for i in input().split()]
#import io, os, sys
#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
 

import bisect
import math
import sys
from collections import defaultdict
def lcm(a,b):
    return ((a*b)//math.gcd(a,b))
 
 
def all_factors(n):
    """returns a sorted list of all distinct factors of n"""
    small, large = [], []
    for i in range(1, int(n**0.5) + 1, 2 if n & 1 else 1):
        if not n % i:
            if(n//i <= 26):
                small.append(i)
            if(n//(n//i) <= 26):
                large.append(n // i)
    if large and small and small[-1] == large[-1]:
        large.pop()
    large.reverse()
    small.extend(large)
    return small
 
mod = 1000000007
 
#if(os.path.exists('input_file.txt')):
#  sys.stdin = open("input.txt", "r")
#  sys.stdout = open("output.txt", "w")
#  sys.stderr = open("error.txt", "w")
 
def gcd(a,b):
    if b > a:
        return gcd(b,a)
    if b == 0:
        return a
    return gcd(b,a%b)
def power(x, y):
    temp = 0
    if(y == 0):
        return 1
    temp = power(x, int(y / 2))
    if (y % 2 == 0):
        return temp * temp
    else:
        return x * temp * temp

for _ in range(1):
    n,k = map(int,input().split())
    l = []
    for i in range(n):
        a,b = map(int,input().split())
        l.append([a,1])
        l.append([b+1,-1])
    l.sort()
    h = [l[0]]
    for i in range(1,len(l)):
        if l[i][0] == h[-1][0]:
            h[-1][1] += l[i][1]
        else:
            h.append(l[i])
    ans = []
    prev = -1
    c = 0
    for i in range(len(h)):
        c += h[i][1]
        if c >= k and prev == -1:
            prev = h[i][0]
        elif c < k and prev != -1:
            ans.append([prev,h[i][0]-1])
            prev = -1
    print(len(ans))
    for i in ans:
        print(*i)
            
        
                
                    
                
            
        
        
    
                    
                
    
    
    
