Ori and Sein have overcome many difficult challenges. They finally lit the Shrouded Lantern and found Gumon Seal, the key to the Forlorn Ruins. When they tried to open the door to the ruins... nothing happened.

Ori was very surprised, but Sein gave the explanation quickly: clever Gumon decided to make an additional defence for the door.

There are $n$ lamps with Spirit Tree's light. Sein knows the time of turning on and off for the $i$-th lamp — $l_i$ and $r_i$ respectively. To open the door you have to choose $k$ lamps in such a way that there will be a moment of time when they all will be turned on.

While Sein decides which of the $k$ lamps to pick, Ori is interested: how many ways there are to pick such $k$ lamps that the door will open? It may happen that Sein may be wrong and there are no such $k$ lamps. The answer might be large, so print it modulo $998\,244\,353$.


-----Input-----

First line contains two integers $n$ and $k$ ($1 \le n \le 3 \cdot 10^5$, $1 \le k \le n$) — total number of lamps and the number of lamps that must be turned on simultaneously.

Next $n$ lines contain two integers $l_i$ ans $r_i$ ($1 \le l_i \le r_i \le 10^9$) — period of time when $i$-th lamp is turned on.


-----Output-----

Print one integer — the answer to the task modulo $998\,244\,353$.


-----Examples-----
Input
7 3
1 7
3 8
4 5
6 7
1 3
5 10
8 9

Output
9
Input
3 1
1 1
2 2
3 3

Output
3
Input
3 2
1 1
2 2
3 3

Output
0
Input
3 3
1 3
2 3
3 3

Output
1
Input
5 2
1 3
2 4
3 5
4 6
5 7

Output
7


-----Note-----

In first test case there are nine sets of $k$ lamps: $(1, 2, 3)$, $(1, 2, 4)$, $(1, 2, 5)$, $(1, 2, 6)$, $(1, 3, 6)$, $(1, 4, 6)$, $(2, 3, 6)$, $(2, 4, 6)$, $(2, 6, 7)$.

In second test case $k=1$, so the answer is 3.

In third test case there are no such pairs of lamps.

In forth test case all lamps are turned on in a time $3$, so the answer is 1.

In fifth test case there are seven sets of $k$ lamps: $(1, 2)$, $(1, 3)$, $(2, 3)$, $(2, 4)$, $(3, 4)$, $(3, 5)$, $(4, 5)$.

Difficulty: MEDIUM_HARD

Solutions:
import sys, os, io
input = sys.stdin.readline
(n, k) = map(int, input().split())
MOD = 998244353
fact = [1] * (n + 1)
rfact = [1] * (n + 1)
for i in range(1, n + 1):
	fact[i] = fact[i - 1] * i % MOD
rfact[n] = pow(fact[n], MOD - 2, MOD)
for i in range(n, 0, -1):
	rfact[i - 1] = rfact[i] * i % MOD

def perm(n, k):
	return fact[n] * rfact[n - k] % MOD

def comb(n, k):
	return fact[n] * rfact[k] * rfact[n - k] % MOD
ans = 0
(L, R) = ([0] * n, [0] * n)
for i in range(n):
	(L[i], R[i]) = map(int, input().split())
compLR = {e: i + 1 for (i, e) in enumerate(sorted(set(L + R)))}
for i in range(n):
	L[i] = compLR[L[i]]
	R[i] = compLR[R[i]]
on = [0] * (n * 2 + 1)
off = [0] * (n * 2 + 2)
for (l, r) in zip(L, R):
	on[l] += 1
	off[r + 1] += 1
cum = 0
for i in range(1, n * 2 + 1):
	cum -= off[i]
	for j in range(1, on[i] + 1):
		old = k - j
		if 0 <= old <= cum:
			ans += comb(cum, old) * comb(on[i], j) % MOD
		ans %= MOD
	cum += on[i]
print(ans)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
N = 300005
factorialNumInverse = [None] * (N + 1)
naturalNumInverse = factorialNumInverse.copy()
fact = factorialNumInverse.copy()

def InverseofNumber(p):
	naturalNumInverse[0] = naturalNumInverse[1] = 1
	for i in range(2, N + 1, 1):
		naturalNumInverse[i] = naturalNumInverse[p % i] * (p - int(p / i)) % p

def InverseofFactorial(p):
	factorialNumInverse[0] = factorialNumInverse[1] = 1
	for i in range(2, N + 1, 1):
		factorialNumInverse[i] = naturalNumInverse[i] * factorialNumInverse[i - 1] % p

def factorial(p):
	fact[0] = 1
	for i in range(1, N + 1):
		fact[i] = fact[i - 1] * i % p

def Binomial(N, R, p):
	ans = fact[N] * factorialNumInverse[R] % p * factorialNumInverse[N - R] % p
	return ans

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(1):
		mod = 998244353
		InverseofNumber(mod)
		InverseofFactorial(mod)
		factorial(mod)
		(n, k) = ria()
		lrl = []
		for i in range(n):
			(L, R) = ria()
			lrl += [2 * L, 2 * R + 1]
		lrl = sorted(lrl)
		ans = 0
		c = 0
		for current_range in lrl:
			if current_range & 1 == 0:
				if c >= k - 1:
					ans += Binomial(c, k - 1, mod)
					ans %= mod
				c += 1
			else:
				c -= 1
		print(ans)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


import sys
import math
import bisect
from sys import stdin, stdout
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')

def qpow(a, b, m):
	ans = 1
	while b:
		if b & 1:
			ans *= a
			ans %= m
		a *= a
		a %= m
		b >>= 1
	return ans
mod = 998244353
(n, k) = inp()
C = [0] * (n + 1)
C[k] = 1
for i in range(k + 1, n + 1):
	C[i] = C[i - 1] * (i - 1) % mod * pow(i - k, mod - 2, mod) % mod
op = []
for _ in range(n):
	(l, r) = inp()
	op.append(2 * l)
	op.append(2 * r + 1)
op.sort()
now = 0
ans = 0
for opt in op:
	if opt & 1 == 0:
		now += 1
		if now >= k:
			ans += C[now]
			ans %= mod
	else:
		now -= 1
print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, k) = map(int, input().split())
l = []
for i in range(n):
	(a, b) = map(int, input().split())
	l.append(2 * a)
	l.append(2 * b + 1)
f = [1] * 300001
fi = [1] * 300001
a = 1
b = 1
m = 998244353
for i in range(1, n + 1):
	a *= i
	a %= m
	f[i] = a
	b *= pow(i, m - 2, m)
	b %= m
	fi[i] = b
l.sort()
c = 0
ans = 0
for i in l:
	if i % 2:
		c -= 1
	else:
		if c >= k - 1:
			ans += f[c] * fi[k - 1] * fi[c - k + 1] % m
			ans %= m
		c += 1
print(ans)


import sys
input = sys.stdin.readline
p = 998244353

def calc(n, r):
	return fact[n] * pow(fact[r] * fact[n - r] % p, p - 2, p) % p
fact = [1, 1]
for i in range(2, 3 * 10 ** 5 + 1):
	fact.append(fact[-1] * i % p)
(n, k) = map(int, input().split())
arr = []
e = []
for i in range(n):
	(l, r) = map(int, input().split())
	arr.append(l)
	e.append(r)
arr.sort()
e.sort()
j = 0
i = 0
s = 0
curr = 0
while j < n:
	if i < n and arr[i] <= e[j]:
		curr += 1
		i += 1
		if curr >= k:
			s += calc(curr - 1, k - 1)
			s = s % p
	else:
		curr += -1
		j += 1
print(s % p)


import array
import itertools
import sys
import time
MOD = 998244353

def main():
	st = time.time()
	(n, k) = list(map(int, input().split()))
	all_input = array.array('L', map(int, sys.stdin.read().split()))
	(l, r) = (all_input[::2], all_input[1::2])
	print('Read', time.time() - st, file=sys.stderr)
	fact = array.array('L', [1] * (n + 1))
	rev = array.array('L', [1] * (n + 1))
	r_fact = array.array('L', [1] * (n + 1))
	for i in range(2, n + 1):
		fact[i] = fact[i - 1] * i % MOD
		(quot, rem) = divmod(MOD, i)
		rev[i] = MOD - quot * rev[rem] % MOD
		r_fact[i] = r_fact[i - 1] * rev[i] % MOD
	print('Fact', time.time() - st, file=sys.stderr)
	sorted_events = sorted(itertools.chain((pos * 2 for pos in l), (pos * 2 + 1 for pos in r)))
	print('Sort', time.time() - st, file=sys.stderr)
	cnt = 0
	res = 0
	for (typ, grp) in itertools.groupby(sorted_events):
		grp_cnt = sum((1 for _ in grp))
		if typ % 2 == 0:
			res -= fact[cnt] * r_fact[cnt - k] if cnt >= k else 0
			cnt += grp_cnt
			res += fact[cnt] * r_fact[cnt - k] if cnt >= k else 0
		else:
			cnt -= grp_cnt
	print('Calc', time.time() - st, file=sys.stderr)
	print(res * r_fact[k] % MOD)
main()


import os
from sys import stdin, stdout

class Input:

	def __init__(self):
		inpt = io.BytesIO(os.read(0, os.fstat(0).st_size)) if 'ONLINE_JUDGE' in os.environ else stdin
		self.lines = inpt.read().splitlines()
		self.idx = 0

	def line(self):
		try:
			return self.lines[self.idx]
		finally:
			self.idx += 1

	def array(self, sep=' ', cast=int):
		return list(map(cast, self.line().split(sep=sep)))

	def known_tests(self):
		(num_of_cases,) = self.array()
		for case in range(num_of_cases):
			yield self

	def unknown_tests(self):
		while self.idx < len(self.lines):
			yield self

def problem_solver():
	MOD = 998244353

	def mod(n, m=MOD):
		return n % m

	def solver(inpt):
		(n, k) = inpt.array()
		b = []
		for i in range(n):
			(x, y) = inpt.array()
			b.append(2 * x + 0)
			b.append(2 * y + 1)
		b.sort()
		mp = [0, 1]
		for i in range(2, n + 1):
			mp.append(MOD - mod(MOD // i * mp[MOD % i]))
		mem = []
		for i in range(n):
			if i < k - 1:
				mem.append(0)
			elif i == k - 1:
				mem.append(1)
			else:
				mem.append(mod(mod(mem[-1] * i) * mp[i - (k - 1)]))
		on = 0
		ans = 0
		for x in b:
			if x & 1:
				on -= 1
			else:
				ans = mod(ans + mem[on])
				on += 1
		print(ans)
	return solver
try:
	solver = problem_solver()
	for tc in Input().unknown_tests():
		solver(tc)
except Exception as e:
	import traceback
	traceback.print_exc(file=stdout)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from bisect import bisect_left
import heapq
(n, k) = map(int, input().split())
seg = []
mod = 998244353
if k == 1:
	print(n)
else:
	for s in range(n):
		(l, r) = map(int, input().split())
		seg.append((l, r))
	fac = [1, 1]
	for s in range(2, n + 1):
		fac.append(fac[-1] * s % mod)
	t = pow(fac[-1], mod - 2, mod)
	inv = [t for s in range(n + 1)]
	for s in range(n - 1, -1, -1):
		inv[s] = inv[s + 1] * (s + 1) % mod
	seg.sort(key=lambda x: x[0])
	heap = []
	for s in range(k - 1):
		heapq.heappush(heap, seg[s][1])
	ans = 0
	for s in range(k - 1, n):
		while len(heap) > 0 and heap[0] < seg[s][0]:
			heapq.heappop(heap)
		if len(heap) >= k - 1:
			r0 = fac[len(heap)]
			r1 = inv[k - 1]
			r2 = inv[len(heap) - (k - 1)]
			ans += r0 * r1 % mod * r2
			ans = ans % mod
		heapq.heappush(heap, seg[s][1])
	print(ans)


import sys
z = sys.stdin.readline
M = 998244353
(n, k) = map(int, z().split())
s = []
e = []
v = [1]
v2 = []
for i in range(1, n + 1):
	v.append(v[-1] * i % M)
v2.append(pow(v[-1], M - 2, M))
for i in range(n):
	v2.append(v2[-1] * (n - i) % M)
v2 = v2[::-1]
for i in range(n):
	(a, b) = map(int, input().split())
	s.append(a)
	e.append(b)
s.sort()
e.sort()
s.append(2 * M)
e.append(2 * M)
si = ei = t = r = 0
while si + ei < n + n:
	while si < n and s[si] <= e[ei]:
		si += 1
		t += 1
	while ei < n and e[ei] < s[si]:
		ei += 1
		t -= 1
		if t >= k - 1:
			r = (r + v[t] * v2[k - 1] * v2[t - k + 1]) % M
print(r)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from heapq import *
from math import gcd, factorial, floor, ceil
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 10 ** 9 + 7

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
N = 3 * (10 ** 5 + 1)
factorialNumInverse = [None] * (N + 1)
naturalNumInverse = [None] * (N + 1)
fact = [None] * (N + 1)

def InverseofNumber(p):
	naturalNumInverse[0] = naturalNumInverse[1] = 1
	for i in range(2, N + 1, 1):
		naturalNumInverse[i] = naturalNumInverse[p % i] * (p - int(p / i)) % p

def InverseofFactorial(p):
	factorialNumInverse[0] = factorialNumInverse[1] = 1
	for i in range(2, N + 1, 1):
		factorialNumInverse[i] = naturalNumInverse[i] * factorialNumInverse[i - 1] % p

def factorial(p):
	fact[0] = 1
	for i in range(1, N + 1):
		fact[i] = fact[i - 1] * i % p

def Binomial(N, R, p):
	ans = fact[N] * factorialNumInverse[R] % p * factorialNumInverse[N - R] % p
	return ans

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def solve(case):
	(n, k) = sep()
	have = []
	for i in range(n):
		(l, r) = sep()
		have.append(2 * l)
		have.append(2 * r + 1)
	have = sorted(have)
	cnt = 0
	currcnt = 0
	for i in range(len(have)):
		temp = have[i]
		if temp % 2 == 0:
			currcnt += 1
		else:
			currcnt -= 1
			if currcnt >= k - 1:
				cnt += Binomial(currcnt, k - 1, 998244353)
				cnt %= 998244353
	print(cnt % 998244353)
p = 998244353
InverseofNumber(p)
InverseofFactorial(p)
factorial(p)
testcase(1)


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
import math
z = 998244353

def inv(a, b):
	return pow(b, z - 2, z) * (a % z) % z
(n, k) = list(map(int, input().split()))
lis = [0] * (n + 1)
lis[k - 1] = 1
for i in range(k, n + 1):
	lis[i] = inv(lis[i - 1] * i, i - k + 1)
l = []
r = []
for i in range(n):
	(u, v) = list(map(int, input().split()))
	l.append(u)
	r.append(v)
l.sort()
r.sort()
i = 0
j = 0
p = 0
ans = 0
while i < n and j < n:
	if l[i] <= r[j]:
		ans += lis[p]
		ans %= z
		p += 1
		i += 1
	else:
		p -= 1
		j += 1
print(ans)


import sys, math
input = lambda : sys.stdin.readline().rstrip('\r\n')
m = 998244353

def modExp(a, n, m=10 ** 9 + 7):
	if n == 0:
		return 1
	elif n == 1:
		return a
	else:
		while n >= 2:
			if n % 2 == 0:
				n = n // 2
				return modExp(a % m * (a % m) % m, n, m)
			else:
				n = (n - 1) // 2
				return a % m * modExp(a % m * (a % m) % m, n, m) % m % m

def nCr(n, r, m):
	return fact[n] * modExp(fact[n - r] * fact[r] % m, m - 2, m) % m
fact = {0: 1, 1: 1}
(n, k) = map(int, input().split())
(a, d) = ([], [])
for i in range(n):
	fact[i + 2] = fact[i + 1] * (i + 2) % m
	(x, y) = map(int, input().split())
	a.append(x)
	d.append(y)
a.sort(reverse=True)
d.sort(reverse=True)
count = 0
out = 0
t = 0
while len(d) != 0:
	if len(a) != 0:
		if a[-1] <= d[-1]:
			count += 1
			a.pop()
		else:
			d.pop()
			count -= 1
			if count + 1 >= k:
				out += nCr(count, k - 1, m)
				out %= m
	else:
		d.pop()
		count -= 1
		if count + 1 >= k:
			out += nCr(count, k - 1, m)
			out %= m
		else:
			break
print(out)


import os, sys
from io import BytesIO, IOBase
from collections import defaultdict
mod = 998244353
fac = [1]
for i in range(1, 300001):
	fac.append(fac[-1] * i % mod)
fac_in = [pow(fac[-1], mod - 2, mod)]
for i in range(300000, 0, -1):
	fac_in.append(fac_in[-1] * i % mod)
fac_in.reverse()

def comb(a, k):
	if a < k:
		return 0
	return fac[a] * fac_in[k] * fac_in[a - k] % mod

def main():
	(n, k) = map(int, input().split())
	mom_pos = defaultdict(list)
	mom_neg = defaultdict(list)
	se = set()
	for j in range(1, n + 1):
		(l, r) = map(int, input().split())
		se.add(l)
		se.add(r)
		mom_pos[l].append(j)
		mom_neg[r].append(-j)
	on = 0
	ans = 0
	for x in sorted(se):
		for _ in mom_pos[x]:
			on += 1
		for _ in mom_neg[x]:
			on -= 1
			ans += comb(on, k - 1)
			ans %= mod
	print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c for j in range(b)] for i in range(a)]

def list3d(a, b, c, d):
	return [[[d for k in range(c)] for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e for l in range(d)] for k in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 998244353
EPS = 10 ** (-10)

def compress(S):
	(zipped, unzipped) = ({}, {})
	for (i, a) in enumerate(sorted(S)):
		zipped[a] = i
		unzipped[i] = a
	return (zipped, unzipped)

class ModTools:

	def __init__(self, MAX, MOD):
		MAX += 1
		self.MAX = MAX
		self.MOD = MOD
		factorial = [1] * MAX
		factorial[0] = factorial[1] = 1
		for i in range(2, MAX):
			factorial[i] = factorial[i - 1] * i % MOD
		inverse = [1] * MAX
		inverse[MAX - 1] = pow(factorial[MAX - 1], MOD - 2, MOD)
		for i in range(MAX - 2, -1, -1):
			inverse[i] = inverse[i + 1] * (i + 1) % MOD
		self.fact = factorial
		self.inv = inverse

	def nCr(self, n, r):
		if n < r:
			return 0
		r = min(r, n - r)
		numerator = self.fact[n]
		denominator = self.inv[r] * self.inv[n - r] % self.MOD
		return numerator * denominator % self.MOD
(N, K) = MAP()
LR = []
S = set()
for i in range(N):
	(l, r) = MAP()
	r += 1
	LR.append((l, r))
	S.add(l)
	S.add(r)
(zipped, _) = compress(S)
M = len(zipped)
lcnt = [0] * M
rcnt = [0] * M
for i in range(N):
	LR[i] = (zipped[LR[i][0]], zipped[LR[i][1]])
	lcnt[LR[i][0]] += 1
	rcnt[LR[i][1]] += 1
cur = 0
ans = 0
mt = ModTools(N, MOD)
for i in range(M):
	cur -= rcnt[i]
	ans += mt.nCr(cur + lcnt[i], K) - mt.nCr(cur, K)
	ans %= MOD
	cur += lcnt[i]
print(ans)


import sys
import math, bisect
sys.setrecursionlimit(10 ** 5)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict

def I():
	return int(sys.stdin.readline())

def neo():
	return map(int, sys.stdin.readline().split())

def Neo():
	return list(map(int, sys.stdin.readline().split()))
mod = 998244353
fact = [1]
for i in range(1, 4 * 10 ** 5):
	fact.append(fact[-1] * i % mod)
(n, k) = neo()
(s, e) = ([], [])
for _ in range(n):
	(l, r) = neo()
	s.append(l)
	e.append(r)
s.sort()
e.sort()
Ans = 0
for i in range(n):
	p = bisect.bisect_right(s, e[i]) - i
	if p >= k:
		Ans += fact[p - 1] * pow(fact[k - 1] * fact[p - k] % mod, mod - 2, mod)
		Ans %= mod
print(Ans)


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from bisect import *
from math import sqrt
import math
from itertools import permutations

def main():
	mod = 998244353
	(n, k) = map(int, input().split())
	f = [1]
	invfac = [0] * (n + 1)
	for i in range(1, n + 1):
		f.append(i * f[-1] % mod)
	invfac[-1] = pow(f[-1], mod - 2, mod)
	for i in range(n - 1, -1, -1):
		invfac[i] = (i + 1) * invfac[i + 1] % mod
	a = []
	for i in range(n):
		(x, y) = map(int, input().split())
		a.append((x, 1))
		a.append((y, -1))
	a.sort(key=lambda x: x[0] * 10000000000 - x[1])
	b = 0
	ans = 0
	for i in a:
		if i[1] == 1:
			if b >= k - 1:
				ans = (ans + f[b] * invfac[b - k + 1] * invfac[k - 1]) % mod
		b += i[1]
	print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


mod = 998244353
maxN = 3 * 10 ** 5 + 9
f = [1] * maxN
for i in range(2, maxN):
	f[i] = f[i - 1] * i % mod
ff = 0
sc = []
n = k = 0
for s in [*open(0)]:
	if ff:
		(l, r) = map(int, s.split())
		sc.append(l * 2)
		sc.append(r * 2 + 1)
	else:
		(n, k) = map(int, s.split())
	ff = 1
sc.sort()
cnt = ans = 0
for i in sc:
	if i % 2:
		cnt -= 1
	else:
		if k - 1 <= cnt:
			ans = (ans + f[cnt] * pow(f[k - 1] * f[cnt - (k - 1)] % mod, mod - 2, mod) % mod) % mod
		cnt += 1
print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
(n, k) = map(int, input().split())
on = list()
off = list()
for j in range(n):
	(l1, r1) = map(int, input().split())
	on.append(l1)
	off.append(r1)
on.sort()
off.sort()
f = [1]
for i in range(1, n + 1):
	f.append(f[-1] * i % 998244353)
inv = [pow(i, 998244351, 998244353) for i in f]
j = 0
ans = 0
count = 0
i = 0
while i < n:
	while on[i] <= off[j]:
		count += 1
		i += 1
		if count > k:
			ans = (ans + f[count - 1] * inv[k - 1] * inv[count - k] % 998244353) % 998244353
		if count == k:
			ans = (ans + 1) % 998244353
		if i == n:
			break
	if i == n:
		break
	while off[j] < on[i]:
		count -= 1
		j += 1
		if j == n:
			break
print(ans)


from sys import stdin

def modfac(n, MOD):
	f = 1
	factorials = [1]
	for m in range(1, n + 1):
		f *= m
		f %= MOD
		factorials.append(f)
	inv = pow(f, MOD - 2, MOD)
	invs = [1] * (n + 1)
	invs[n] = inv
	for m in range(n, 1, -1):
		inv *= m
		inv %= MOD
		invs[m - 1] = inv
	return (factorials, invs)

def modnCr(n, r):
	return fac[n] * inv[n - r] * inv[r] % mod
mod = 998244353
(fac, inv) = modfac(400000, mod)
(n, k) = map(int, stdin.readline().split())
l = [float('inf')]
r = [float('inf')]
for i in range(n):
	(L, R) = map(int, stdin.readline().split())
	l.append(L)
	r.append(R)
l.sort()
l.reverse()
r.sort()
r.reverse()
ans = 0
now = 0
for i in range(2 * n):
	if l[-1] <= r[-1]:
		now += 1
		del l[-1]
		if now >= k:
			ans += modnCr(now - 1, k - 1)
			ans %= mod
	else:
		now -= 1
		del r[-1]
print(ans % mod)


from collections import defaultdict
from sys import stdin, stdout

def input():
	return stdin.readline().strip()

def make_nCr_mod(max_n=5 * 10 ** 5 + 100, mod=998244353):
	(fact, inv_fact) = ([0] * (max_n + 1), [0] * (max_n + 1))
	fact[0] = 1
	for i in range(max_n):
		fact[i + 1] = fact[i] * (i + 1) % mod
	inv_fact[-1] = pow(fact[-1], mod - 2, mod)
	for i in reversed(range(max_n)):
		inv_fact[i] = inv_fact[i + 1] * (i + 1) % mod

	def nCr_mod(n, r):
		res = 1
		while n or r:
			(a, b) = (n % mod, r % mod)
			if a < b:
				return 0
			res = res * fact[a] % mod * inv_fact[b] % mod * inv_fact[a - b] % mod
			n //= mod
			r //= mod
		return res
	return nCr_mod
nCr_mod = make_nCr_mod()
MODULUS = 998244353
(N, K) = input().split()
N = int(N)
K = int(K)
num_start = defaultdict(int)
num_end = defaultdict(int)
indexes = []
for _ in range(N):
	(l, r) = input().split()
	l = int(l)
	r = int(r)
	num_start[l] += 1
	num_end[r] += 1
	indexes += [l, r]
indexes = sorted(set(indexes))
rs = 0
last_rs = None
ret = 0
for i in indexes:
	rs += num_start[i]
	c = rs - num_end[i]
	ret += nCr_mod(rs, K)
	ret -= nCr_mod(c, K)
	rs -= num_end[i]
	last_rs = rs
ret %= MODULUS
ret += MODULUS
ret %= MODULUS
print(ret)


import sys
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
MOD = 998244353
(n, k) = map(int, input().split())
a = [tuple(map(int, input().split())) for _ in range(n)]
fac = [1] * (n + 1)
for i in range(2, n + 1):
	fac[i] = fac[i - 1] * i % MOD
ifac = [1] * (n + 1)
ifac[n] = pow(fac[n], MOD - 2, MOD)
for i in range(n - 1, 1, -1):
	ifac[i] = ifac[i + 1] * (i + 1) % MOD
comb = lambda n, k: fac[n] * ifac[k] % MOD * ifac[n - k] % MOD if 0 <= k <= n else 0
e = [s * 2 for (s, _) in a] + [e * 2 + 1 for (_, e) in a]
e.sort()
cur = ways = 0
for t in e:
	if t % 2:
		cur -= 1
	else:
		ways += comb(cur, k - 1)
		cur += 1
print(ways % MOD)


import array
import collections
import itertools
import sys
import time
MOD = 998244353

def main():
	st = time.time()
	(n, k) = list(map(int, input().split()))
	all_input = list(map(int, sys.stdin.read().split()))
	print('Read', time.time() - st, file=sys.stderr)
	rev = array.array('L', [1] * (n + 1))
	for i in range(2, n + 1):
		(quot, rem) = divmod(MOD, i)
		rev[i] = -quot * rev[rem] % MOD
	c_nk = array.array('L', [0] * (n + 1))
	c_nk[k] = 1
	for i in range(k + 1, n + 1):
		c_nk[i] = c_nk[i - 1] * i * rev[i - k] % MOD
	print('Binom', time.time() - st, file=sys.stderr)
	events = collections.Counter(sorted(itertools.chain((pos * 2 for pos in all_input[::2]), (pos * 2 + 1 for pos in all_input[1::2]))))
	print('Sort', time.time() - st, file=sys.stderr)
	cnt = 0
	res = 0
	for (typ, grp_cnt) in events.items():
		if typ % 2 == 0:
			res -= c_nk[cnt]
			cnt += grp_cnt
			res += c_nk[cnt]
		else:
			cnt -= grp_cnt
	print('Calc', time.time() - st, file=sys.stderr)
	print(res % MOD)
main()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
from collections import defaultdict as dc
(n, k) = RL()
M = 998244353
v = [1] * (n + 1)
for i in range(1, n + 1):
	v[i] = v[i - 1] * i % M
v2 = [0] * (n + 1)
v2[n] = pow(v[n], M - 2, M)
v2[0] = 1
for i in range(n - 1, 0, -1):
	v2[i] = v2[i + 1] * (i + 1) % M
res = 0
ll = dc(set)
rr = dc(set)
for i in range(n):
	(l, r) = RL()
	ll[l].add(i)
	rr[r + 1].add(i)
al = sorted(list(set(list(ll.keys()) + list(rr.keys()))))
last = al[0]
now = ll[last]
ln = len(now)
if ln >= k:
	res += v[ln] * v2[k] * v2[ln - k] % M
for time in al[1:]:
	now -= rr[time]
	ln = len(now)
	if ln >= k:
		res -= v[ln] * v2[k] * v2[ln - k] % M
	now |= ll[time]
	ln = len(now)
	if ln >= k:
		res += v[ln] * v2[k] * v2[ln - k] % M
	res %= M
print(res)


import io
import os
MOD_NUM = 998244353
cin = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
FACTORIAL_CACHE = []
INV_FACTORIAL_CACHE = []
MOD_INV_CACHE = {}

def get_input():
	return cin().split()

def get_int_input():
	return map(int, get_input())

def init_factorial_cache(N):
	globals()['FACTORIAL_CACHE'] = [1] * (N + 1)
	for i in range(2, N + 1):
		FACTORIAL_CACHE[i] = FACTORIAL_CACHE[i - 1] * i % MOD_NUM
	globals()['INV_FACTORIAL_CACHE'] = [1] * (N + 1)
	INV_FACTORIAL_CACHE[N] = pow(FACTORIAL_CACHE[N], MOD_NUM - 2, MOD_NUM)
	for i in range(N):
		INV_FACTORIAL_CACHE[N - i - 1] = INV_FACTORIAL_CACHE[N - i] * (N - i) % MOD_NUM

def factorial_with_mod(x):
	return FACTORIAL_CACHE[x]

def inv_factorial_with_mod(x):
	return INV_FACTORIAL_CACHE[x]

def nCk(n, k):
	if n < k:
		return 0
	comb = factorial_with_mod(n) * inv_factorial_with_mod(k) * inv_factorial_with_mod(n - k)
	comb %= MOD_NUM
	return comb

def rescue_nibel(N, K, starts, ends):
	ans = 0
	starts.sort()
	ends.sort()
	i = 0
	j = 0
	count_of_on = 0
	while i < N:
		if starts[i] < ends[j]:
			count_of_on += 1
			ans += nCk(count_of_on - 1, K - 1)
			ans %= MOD_NUM
			i += 1
		else:
			count_of_on -= 1
			j += 1
	return ans

def main():
	(N, K) = get_int_input()
	init_factorial_cache(N)
	timings = [0] * N
	starts = [0] * N
	ends = [0] * N
	for i in range(N):
		(s, e) = get_int_input()
		starts[i] = s
		ends[i] = e + 1
	print(rescue_nibel(N, K, starts, ends))
main()


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))

def make_nCr_mod(max_n=2 * 10 ** 5, mod=10 ** 9 + 7):
	max_n = min(max_n, mod - 1)
	(fact, inv_fact) = ([0] * (max_n + 1), [0] * (max_n + 1))
	fact[0] = 1
	for i in range(max_n):
		fact[i + 1] = fact[i] * (i + 1) % mod
	inv_fact[-1] = pow(fact[-1], mod - 2, mod)
	for i in reversed(range(max_n)):
		inv_fact[i] = inv_fact[i + 1] * (i + 1) % mod

	def nCr_mod(n, r):
		res = 1
		while n or r:
			(a, b) = (n % mod, r % mod)
			if a < b:
				return 0
			res = res * fact[a] % mod * inv_fact[b] % mod * inv_fact[a - b] % mod
			n //= mod
			r //= mod
		return res
	return nCr_mod

def bucketsort(order, seq):
	buckets = [0] * (max(seq) + 1)
	for x in seq:
		buckets[x] += 1
	for i in range(len(buckets) - 1):
		buckets[i + 1] += buckets[i]
	new_order = [-1] * len(seq)
	for i in reversed(order):
		x = seq[i]
		idx = buckets[x] = buckets[x] - 1
		new_order[idx] = i
	return new_order

def ordersort(order, seq, reverse=False):
	bit = max(seq).bit_length() >> 1
	mask = (1 << bit) - 1
	order = bucketsort(order, [x & mask for x in seq])
	order = bucketsort(order, [x >> bit for x in seq])
	if reverse:
		order.reverse()
	return order

def long_ordersort(order, seq):
	order = ordersort(order, [int(i & 2147483647) for i in seq])
	return ordersort(order, [int(i >> 31) for i in seq])

def multikey_ordersort(order, *seqs, sort=ordersort):
	for i in reversed(range(len(seqs))):
		order = sort(order, seqs[i])
	return order

def main():
	MOD = 998244353
	nCr = make_nCr_mod(3 * 10 ** 5 + 1, MOD)
	(n, k) = map(int, input().split())
	(l, r) = ([0] * n, [0] * n)
	for i in range(n):
		(l[i], r[i]) = map(int, input().split())
	order = multikey_ordersort(range(n), l, r)
	off_times = SortedList([])
	sol = 0
	for m in order:
		lamp = [l[m], r[m]]
		removed = 0
		while len(off_times) and off_times[0] < lamp[0]:
			off_times.pop(0)
			removed += 1
		term = 0
		for i in range(1, min(k, removed) + 1):
			if k - i > len(off_times):
				continue
			term += nCr(removed, i) * nCr(len(off_times), k - i) % MOD
		sol = (sol + term) % MOD
		off_times.add(lamp[1])
	if len(off_times) >= k:
		sol = (sol + nCr(len(off_times), k)) % MOD
	print(sol)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from sys import stdin
import heapq
input = stdin.readline
MOD = 998244353

def solve():
	(n, k) = map(int, input().split())
	p = [tuple(map(int, inp.split())) for inp in stdin.read().splitlines()]
	p.sort(key=lambda x: x[0])
	fac = [1, 1] + [0] * n
	inv = [1, 1] + [0] * n
	for i in range(2, n + 1):
		fac[i] = fac[i - 1] * i % MOD
	inv[n] = pow(fac[n], MOD - 2, MOD)
	for i in range(n - 1, 1, -1):
		inv[i] = inv[i + 1] * (i + 1) % MOD

	def c(a, b):
		return fac[b] * inv[a] * inv[b - a] % MOD
	h = []
	res = 0
	for (i, v) in enumerate(p):
		while h and h[0] < v[0]:
			heapq.heappop(h)
		if len(h) >= k - 1:
			res += c(k - 1, len(h))
			res %= MOD
		heapq.heappush(h, v[1])
	print(res)
solve()


import os, sys

def inp():
	return sys.stdin.buffer.readline().rstrip()

def inpa():
	return tuple(map(int, inp().split()))

def out(var):
	sys.stdout.write(str(var) + '\n')

def outa(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def setup():
	dir_path = os.path.dirname(os.path.realpath(__file__))
	sys.stdin = open(os.path.join(dir_path, 'input.txt'), 'r')
	sys.stdout = open(os.path.join(dir_path, 'output.txt'), 'w')
MAXN = 3 * 10 ** 5
mod = 998244353
fac = [1]
for i in range(1, MAXN + 1):
	fac.append(fac[-1] * i % mod)
invf = [pow(fac[-1], mod - 2, mod)]
for i in range(MAXN, 0, -1):
	invf.append(i * invf[-1] % mod)
invf = invf[::-1]

def C(n, k):
	return fac[n] * invf[n - k] * invf[k] % mod if n >= k else 0

def solve(arr, k):
	ans = cur_total = 0
	for time in arr:
		if time % 2 == 0:
			ans += C(cur_total, k - 1) % mod
			cur_total += 1
		else:
			cur_total -= 1
	return ans % mod
(n, k) = inpa()
arr = []
for _ in range(n):
	(l, r) = inpa()
	arr.append(2 * l)
	arr.append(2 * r + 1)
arr.sort()
out(solve(arr, k))


import sys
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, k) = map(int, input().split())
mod = 998244353
Combi = [1] * (n + 1)
Combi[k - 1] = 1
for i in range(k, n + 1):
	Combi[i] = Combi[i - 1] * i * pow(i - (k - 1), mod - 2, mod) % mod
LAMPS = []
for i in range(n):
	(l, r) = map(int, input().split())
	LAMPS.append((l, 0))
	LAMPS.append((r, 1))
from operator import itemgetter
LAMPS.sort(key=itemgetter(1))
LAMPS.sort(key=itemgetter(0))
NOW = 0
ANS = 0
for (l, t) in LAMPS:
	if t == 0:
		if NOW >= k - 1:
			ANS = ANS + Combi[NOW]
			ANS %= mod
		NOW += 1
	else:
		NOW -= 1
print(ANS)


import math
from sys import stdin

def put():
	return map(int, stdin.readline().split())

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def inv(a, b):
	g = math.gcd(b, m)
	return pow(b, m - 2, m) * (a % m) % m
import math
for _ in range(1):
	(n, k) = put()
	l = []
	r = []
	for i in range(n):
		(a, b) = put()
		l.append(a)
		r.append(b)
	s = 0
	ans = 0
	l.sort()
	r.sort()
	indl = 0
	indr = 0
	m = 998244353
	C = [0] * (n + 1)
	C[k - 1] = 1
	for i in range(k, n + 1):
		C[i] = inv(C[i - 1] * (i % m), (i - k + 1) % m)
		C[i] %= m
	while indl < n and indr < n:
		if l[indl] <= r[indr]:
			indl += 1
			if s >= k - 1:
				ans += C[s]
			s += 1
		elif l[indl] > r[indr]:
			indr += 1
			s -= 1
	print(int(ans) % 998244353)


import sys, io, os
z = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
M = 998244353
(n, k) = map(int, z().split())
s = []
e = []
v = [1]
v2 = []
for i in range(1, n + 1):
	v.append(v[-1] * i % M)
v2.append(pow(v[-1], M - 2, M))
for i in range(n):
	v2.append(v2[-1] * (n - i) % M)
v2 = v2[::-1]
for i in range(n):
	(a, b) = map(int, z().split())
	s.append(a)
	e.append(b)
s.sort()
e.sort()
s.append(2 * M)
e.append(2 * M)
si = ei = t = r = 0
while si + ei < n + n:
	while si < n and s[si] <= e[ei]:
		si += 1
		t += 1
	while ei < n and e[ei] < s[si]:
		ei += 1
		t -= 1
		if t >= k - 1:
			r = (r + v[t] * v2[k - 1] % M * v2[t - k + 1]) % M
print(r)


class Combination:

	def __init__(self, n, MOD):
		self.fact = [1]
		for i in range(1, n + 1):
			self.fact.append(self.fact[-1] * i % MOD)
		self.inv_fact = [0] * (n + 1)
		self.inv_fact[n] = pow(self.fact[n], MOD - 2, MOD)
		for i in reversed(range(n)):
			self.inv_fact[i] = self.inv_fact[i + 1] * (i + 1) % MOD
		self.MOD = MOD

	def inverse(self, k):
		return self.inv_fact[k] * self.fact[k - 1] % self.MOD

	def factorial(self, k):
		return self.fact[k]

	def inverse_factorial(self, k):
		return self.inv_fact[k]

	def permutation(self, k, r):
		if k < r:
			return 0
		return self.fact[k] * self.inv_fact[k - r] % self.MOD

	def combination(self, k, r):
		if k < r:
			return 0
		return self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r] % self.MOD
import heapq
import sys
input = sys.stdin.buffer.readline
(n, k) = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]
MOD = 998244353
comb = Combination(5 * 10 ** 5, MOD)
info = sorted(info)
q = []
ans = 0
for (l, r) in info:
	while q and q[0] < l:
		heapq.heappop(q)
	heapq.heappush(q, r)
	cnt = len(q)
	ans += comb.combination(cnt - 1, k - 1)
	ans %= MOD
print(ans)


import sys

def prepare(n):
	global facts, inv_facts
	facts = [1, 1]
	inv_facts = [1 for i in range(n)]
	for i in range(2, n):
		facts.append(facts[i - 1] * i % m)
	inv_facts[-1] = pow(facts[-1], m - 2, m)
	for i in range(n - 2, 0, -1):
		inv_facts[i] = inv_facts[i + 1] * (i + 1) % m

def inv_fact(n):
	return inv_facts[n]

def fact(n):
	return facts[n]

def c(n, k):
	if k < 0 or k > n:
		return 0
	return fact(n) * (inv_fact(k) * inv_fact(n - k) % m) % m
(n, k) = map(int, sys.stdin.readline().split())
a = []
for i in range(n):
	(l, r) = map(int, sys.stdin.readline().split())
	a.append(l << 1)
	a.append((r << 1) + 1)
a.sort()
s = 0
m = 998244353
prepare(300010)
ans = 0
for b in a:
	if b & 1 == 0:
		s += 1
		ans += c(s - 1, k - 1)
		if ans >= m:
			ans -= m
	else:
		s -= 1
print(ans)


from functools import lru_cache
from sys import stdin, stdout
import sys
from math import *
input = stdin.readline
N = 400000
factorialNumInverse = [None] * (N + 1)
naturalNumInverse = [None] * (N + 1)
fact = [None] * (N + 1)

def InverseofNumber(p):
	naturalNumInverse[0] = naturalNumInverse[1] = 1
	for i in range(2, N + 1, 1):
		naturalNumInverse[i] = naturalNumInverse[p % i] * (p - int(p / i)) % p

def InverseofFactorial(p):
	factorialNumInverse[0] = factorialNumInverse[1] = 1
	for i in range(2, N + 1, 1):
		factorialNumInverse[i] = naturalNumInverse[i] * factorialNumInverse[i - 1] % p

def factorial(p):
	fact[0] = 1
	for i in range(1, N + 1):
		fact[i] = fact[i - 1] * i % p

def Binomial(N, R, p):
	ans = fact[N] * factorialNumInverse[R] % p * factorialNumInverse[N - R] % p
	return ans
(n, k) = map(int, input().split())
s = {}
e = {}
a = []
for i in range(n):
	(x, y) = map(int, input().split())
	if s.get(x) == None:
		s[x] = 0
		a.append(x)
	s[x] += 1
	if e.get(y) == None:
		e[y] = 0
		a.append(y)
	e[y] += 1
a = list(set(a))
a.sort()
t = 0
ans = 0
mod = 998244353
InverseofNumber(mod)
InverseofFactorial(mod)
factorial(mod)
for i in range(len(a)):
	x = 0
	if s.get(a[i]) != None:
		t += s[a[i]]
		x = s[a[i]]
	if x != 0 and t >= k:
		temp = t
		for j in range(x):
			temp -= 1
			if temp >= k - 1:
				ans = (ans + Binomial(temp, k - 1, mod)) % mod
	if e.get(a[i]) != None:
		t -= e[a[i]]
print(ans % mod)


from collections import defaultdict
import sys
input = sys.stdin.buffer.readline
MOD = 998244353
(n, k) = map(int, input().split())
(add, rmv, pos) = (defaultdict(int), defaultdict(int), set([]))
for _ in range(n):
	(l, r) = map(int, input().split())
	(add[l], rmv[r]) = (add[l] + 1, rmv[r] + 1)
	pos.add(l)
	pos.add(r)
(fac, ifac) = ([1] * (n + 1), [1] * (n + 1))
for i in range(1, n + 1):
	fac[i] = fac[i - 1] * i % MOD
	ifac[i] = pow(fac[i], MOD - 2, MOD)

def comb(m, r):
	return fac[m] * ifac[m - r] % MOD * ifac[r] % MOD
pos = list(sorted(list(pos)))
(cur, sm) = (0, 0)
for p in pos:
	if cur >= k:
		sm = (sm - comb(cur, k)) % MOD
	cur += add[p]
	if cur >= k:
		sm = (sm + comb(cur, k)) % MOD
	cur -= rmv[p]
print(sm)


import itertools
import functools
import math
import sys
from collections import defaultdict
import sys

def stdinWrapper():
	data = '5 2\n1 3\n2 4\n3 5\n4 6\n5 7\n'
	for line in data.split('\n'):
		yield line
if '--debug' not in sys.argv:

	def stdinWrapper():
		while True:
			yield sys.stdin.readline()
inputs = stdinWrapper()

def inputWrapper():
	return next(inputs)

def getType(_type):
	return _type(inputWrapper())

def getArray(_type):
	return [_type(x) for x in inputWrapper().split()]

def solve(b, k):
	LIMIT = 998244353
	N = 3 * 100000 + 5
	fact = [0] * N
	fact[0] = 1
	for i in range(1, N):
		fact[i] = fact[i - 1] * i % LIMIT

	def fastpow(a, b):
		res = 1
		a %= LIMIT
		while b > 0:
			if b & 1:
				res = res * a % LIMIT
			a = a * a % LIMIT
			b >>= 1
		return res

	def choices(n, k):
		return fact[n] * fastpow(fact[k] * fact[n - k] % LIMIT, LIMIT - 2) % LIMIT
	events = []
	for (start, end) in b:
		events.append(start * 2)
		events.append(end * 2 + 1)
	events.sort()
	w = 0
	s = 0
	for e in events:
		if e % 2:
			s -= 1
		else:
			if s >= k - 1:
				w += choices(s, k - 1)
				w %= LIMIT
			s += 1
	return (w + LIMIT) % LIMIT
(n, k) = getArray(int)
bulbs = [getArray(int) for _ in range(n)]
res = solve(bulbs, k)
print(res)


import io
import os
MAX_N = 3 * 10 ** 5
MOD = 998244353

def modInverse(a, p):
	return pow(a, p - 2, p)
fact = [1]
for i in range(1, MAX_N + 1):
	fact.append(fact[-1] * i % MOD)
invFact = [0] * (MAX_N + 1)
invFact[MAX_N] = modInverse(fact[MAX_N], MOD)
for i in range(MAX_N - 1, -1, -1):
	invFact[i] = invFact[i + 1] * (i + 1) % MOD
	assert fact[i] * invFact[i] % MOD == 1

def nCr(n, r):
	return fact[n] * invFact[r] * invFact[n - r] % MOD

def solve(N, K, LR):
	endpoints = []
	for (l, r) in LR:
		l -= 1
		r -= 1
		endpoints.append(2 * l + 0)
		endpoints.append(2 * r + 1)
	endpoints.sort()
	ans = 0
	overlaps = 0
	for tup in endpoints:
		(x, kind) = divmod(tup, 2)
		if kind == 0:
			if overlaps >= K - 1:
				ans += nCr(overlaps, K - 1)
				ans %= MOD
			overlaps += 1
		else:
			overlaps -= 1
	return ans
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(N, K) = [int(x) for x in input().split()]
LR = [[int(x) for x in input().split()] for i in range(N)]
ans = solve(N, K, LR)
print(ans)


from functools import cmp_to_key
from collections import deque
from heapq import heappush, heappop
from math import log, ceil
import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def ii():
	return int(inp())

def li(lag=0):
	l = list(map(int, inp().split()))
	if lag != 0:
		for i in range(len(l)):
			l[i] += lag
	return l

def mi(lag=0):
	matrix = list()
	for i in range(n):
		matrix.append(li(lag))
	return matrix

def sli():
	return list(map(str, inp().split()))

def print_list(lista, space=' '):
	print(space.join(map(str, lista)))

class UnionFind:

	def __init__(self, n):
		self.parent = list(range(n))
		self.size = [1] * n
		self.num_sets = n

	def find(self, a):
		to_update = []
		while a != self.parent[a]:
			to_update.append(a)
			a = self.parent[a]
		for b in to_update:
			self.parent[b] = a
		return self.parent[a]

	def merge(self, a, b):
		a = self.find(a)
		b = self.find(b)
		if a == b:
			return
		if self.size[a] < self.size[b]:
			(a, b) = (b, a)
		self.num_sets -= 1
		self.parent[b] = a
		self.size[a] += self.size[b]

	def set_size(self, a):
		return self.size[self.find(a)]

	def __len__(self):
		return self.num_sets

def bisect_left(a, x):
	left = 0
	right = len(a)
	while left < right:
		mid = (left + right) // 2
		if a[mid] < x:
			left = mid + 1
		else:
			right = mid
	return left

def bisect_right(a, x):
	left = 0
	right = len(a)
	while left < right:
		mid = (left + right) // 2
		if a[mid] > x:
			right = mid
		else:
			left = mid + 1
	return left

def bisect_elements(a, x):
	return bisect_right(a, x) - bisect_left(a, x)

def custom_sort(lista):

	def cmp(x, y):
		if x + y > y + x:
			return 1
		else:
			return -1
	return sorted(lista, key=cmp_to_key(cmp))
MOD = 998244353
maxN = 3 * 10 ** 5 + 7
FACT = [0] * maxN

def add(x, y):
	return (x + y) % MOD

def multiply(x, y):
	return x * y % MOD

def power(x, y):
	if y == 0:
		return 1
	elif y % 2:
		return multiply(x, power(x, y - 1))
	else:
		a = power(x, y // 2)
		return multiply(a, a)

def inverse(x):
	return power(x, MOD - 2)

def divide(x, y):
	return multiply(x, inverse(y))

def allFactorials():
	FACT[0] = 1
	for i in range(1, maxN):
		FACT[i] = multiply(i, FACT[i - 1])

def coeffBinom(n, k):
	if n < k:
		return 0
	return divide(FACT[n], multiply(FACT[k], FACT[n - k]))

def primes(N):
	smallest_prime = [1] * (N + 1)
	prime = []
	smallest_prime[0] = 0
	smallest_prime[1] = 0
	for i in range(2, N + 1):
		if smallest_prime[i] == 1:
			prime.append(i)
			smallest_prime[i] = i
		j = 0
		while j < len(prime) and i * prime[j] <= N:
			smallest_prime[i * prime[j]] = min(prime[j], smallest_prime[i])
			j += 1
	return (prime, smallest_prime)

def gcd(a, b):
	a = abs(a)
	b = abs(b)
	(s, t, r) = (0, 1, b)
	(old_s, old_t, old_r) = (1, 0, a)
	while r != 0:
		quotient = old_r // r
		(old_r, r) = (r, old_r - quotient * r)
		(old_s, s) = (s, old_s - quotient * s)
		(old_t, t) = (t, old_t - quotient * t)
	return (old_r, old_s, old_t)

def create_graph(n, m, undirected=1, unweighted=1):
	graph = [[] for i in range(n)]
	if unweighted:
		for i in range(m):
			[x, y] = li(lag=-1)
			graph[x].append(y)
			if undirected:
				graph[y].append(x)
	else:
		for i in range(m):
			[x, y, w] = li(lag=-1)
			w += 1
			graph[x].append([y, w])
			if undirected:
				graph[y].append([x, w])
	return graph

def create_tree(n, unweighted=1):
	children = [[] for i in range(n)]
	if unweighted:
		for i in range(n - 1):
			[x, y] = li(lag=-1)
			children[x].append(y)
			children[y].append(x)
	else:
		for i in range(n - 1):
			[x, y, w] = li(lag=-1)
			w += 1
			children[x].append([y, w])
			children[y].append([x, w])
	return children

def create_edges(m, unweighted=0):
	edges = list()
	if unweighted:
		for i in range(m):
			edges.append(li(lag=-1))
	else:
		for i in range(m):
			[x, y, w] = li(lag=-1)
			w += 1
			edges.append([w, x, y])
	return edges

def dist(tree, n, A, B=-1):
	s = [[A, 0]]
	(massimo, massimo_nodo) = (0, 0)
	distanza = -1
	v = [-1] * n
	while s:
		(el, dis) = s.pop()
		if dis > massimo:
			massimo = dis
			massimo_nodo = el
		if el == B:
			distanza = dis
		for child in tree[el]:
			if v[child] == -1:
				v[child] = 1
				s.append([child, dis + 1])
	return (massimo, massimo_nodo, distanza)

def diameter(tree):
	(_, foglia, _) = dist(tree, n, 0)
	(diam, _, _) = dist(tree, n, foglia)
	return diam

def dfs(graph, n, A):
	v = [-1] * n
	s = [[A, 0]]
	v[A] = 0
	while s:
		(el, dis) = s.pop()
		for child in graph[el]:
			if v[child] == -1:
				v[child] = dis + 1
				s.append([child, dis + 1])
	return v

def bfs(graph, n, A):
	v = [-1] * n
	s = deque()
	s.append([A, 0])
	v[A] = 0
	while s:
		(el, dis) = s.popleft()
		for child in graph[el]:
			if v[child] == -1:
				v[child] = dis + 1
				s.append([child, dis + 1])
	return v

def connected(graph, n):
	v = dfs(graph, n, 0)
	for el in v:
		if el == -1:
			return False
	return True

def topological(graph, n):
	indegree = [0] * n
	for el in range(n):
		for child in graph[el]:
			indegree[child] += 1
	s = deque()
	for el in range(n):
		if indegree[el] == 0:
			s.append(el)
	order = []
	while s:
		el = s.popleft()
		order.append(el)
		for child in graph[el]:
			indegree[child] -= 1
			if indegree[child] == 0:
				s.append(child)
	if n == len(order):
		return (False, order)
	else:
		return (True, [])

def bipartite(graph, n):
	color = [-1] * n
	color[0] = 0
	s = [0]
	while s:
		el = s.pop()
		for child in graph[el]:
			if color[child] == color[el]:
				return False
			if color[child] == -1:
				s.append(child)
			color[child] = 1 - color[el]
	return True

def dijkstra(graph, n, A):
	dist = [float('inf') for i in range(n)]
	prev = [-1 for i in range(n)]
	dist[A] = 0
	pq = []
	heappush(pq, [0, A])
	while pq:
		[d_v, v] = heappop(pq)
		if d_v != dist[v]:
			continue
		for (to, w) in graph[v]:
			if dist[v] + w < dist[to]:
				dist[to] = dist[v] + w
				prev[to] = v
				heappush(pq, [dist[to], to])
	return (dist, prev)

def dijkstra_0_1(graph, n, A):
	dist = [float('inf') for i in range(n)]
	dist[A] = 0
	p = deque()
	p.append(A)
	while p:
		v = p.popleft()
		for (to, w) in graph[v]:
			if dist[v] + w < dist[to]:
				dist[to] = dist[v] + w
			if w == 1:
				q.append(to)
			else:
				q.appendleft(to)
	return dist

def floyd_warshall(graph, n):
	dist = [[float('inf') for _ in range(n)] for _ in range(n)]
	for i in range(n):
		dist[i][i] = 0
		for (child, d) in graph[i]:
			dist[i][child] = d
			dist[child][i] = d
	for k in range(n):
		for i in range(n):
			for j in range(j):
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
	return dist

def minimum_spanning_tree(edges, n):
	edges = sorted(edges)
	union_find = UnionFind(n)
	used_edges = list()
	for (w, x, y) in edges:
		if union_find.find(x) != union_find.find(y):
			union_find.merge(x, y)
			used_edges.append([w, x, y])
	return used_edges

def parents_children_root_unrooted_tree(tree, n, root=0):
	q = deque()
	visited = [0] * n
	parent = [-1] * n
	children = [[] for i in range(n)]
	q.append(root)
	while q:
		all_done = 1
		visited[q[0]] = 1
		for child in tree[q[0]]:
			if not visited[child]:
				all_done = 0
				q.appendleft(child)
		if all_done:
			for child in tree[q[0]]:
				if parent[child] == -1:
					parent[q[0]] = child
					children[child].append(q[0])
			q.popleft()
	return (parent, children)

def all_longest_path_passing_from_node(parent, children, n):
	q = deque()
	visited = [len(children[i]) for i in range(n)]
	downwards = [[0, 0] for i in range(n)]
	upward = [1] * n
	longest_path = [1] * n
	for i in range(n):
		if not visited[i]:
			q.append(i)
			downwards[i] = [1, 0]
	while q:
		node = q.popleft()
		if parent[node] != -1:
			visited[parent[node]] -= 1
			if not visited[parent[node]]:
				q.append(parent[node])
		else:
			root = node
		for child in children[node]:
			downwards[node] = sorted([downwards[node][0], downwards[node][1], downwards[child][0] + 1], reverse=True)[0:2]
	s = [node]
	while s:
		node = s.pop()
		if parent[node] != -1:
			if downwards[parent[node]][0] == downwards[node][0] + 1:
				upward[node] = 1 + max(upward[parent[node]], downwards[parent[node]][1])
			else:
				upward[node] = 1 + max(upward[parent[node]], downwards[parent[node]][0])
		longest_path[node] = downwards[node][0] + downwards[node][1] + upward[node] - min([downwards[node][0], downwards[node][1], upward[node]]) - 1
		for child in children[node]:
			s.append(child)
	return longest_path

def finding_ancestors(parent, queries, n):
	steps = int(ceil(log(n, 2)))
	ancestors = [[-1 for i in range(n)] for j in range(steps)]
	ancestors[0] = parent
	for i in range(1, steps):
		for node in range(n):
			if ancestors[i - 1][node] != -1:
				ancestors[i][node] = ancestors[i - 1][ancestors[i - 1][node]]
	result = []
	for (node, k) in queries:
		ans = node
		if k >= n:
			ans = -1
		i = 0
		while k > 0 and ans != -1:
			if k % 2:
				ans = ancestors[i][ans]
			k = k // 2
			i += 1
		result.append(ans)
	return result

def prefix_sum(arr):
	r = [0] * (len(arr) + 1)
	for (i, el) in enumerate(arr):
		r[i + 1] = r[i] + el
	return r

def nearest_from_the_left_smaller_elements(arr):
	n = len(arr)
	res = [-1] * n
	s = []
	for (i, el) in enumerate(arr):
		while s and s[-1] >= el:
			s.pop()
		if s:
			res[i] = s[-1]
		s.append(el)
	return res

def sliding_window_minimum(arr, k):
	res = []
	q = deque()
	for (i, el) in enumerate(arr):
		while q and arr[q[-1]] >= el:
			q.pop()
		q.append(i)
		while q and q[0] <= i - k:
			q.popleft()
		if i >= k - 1:
			res.append(arr[q[0]])
	return res
allFactorials()
(n, k) = li()
ev = []
for i in range(n):
	a = li()
	ev.append(2 * a[0])
	ev.append(2 * a[1] + 1)
ev.sort()
c = 0
s = 0
for ap in ev:
	if ap % 2 == 0:
		c += 1
		s = add(s, coeffBinom(c - 1, k - 1))
	else:
		c -= 1
print(s)


import sys
inp = sys.stdin.buffer.readline
inar = lambda : list(map(int, inp().split()))
inin = lambda : int(inp())
inst = lambda : inp().decode().strip()

class Combination:

	def __init__(self, n, MOD):
		self.fact = [1]
		for i in range(1, n + 1):
			self.fact.append(self.fact[-1] * i % MOD)
		self.inv_fact = [0] * (n + 1)
		self.inv_fact[n] = pow(self.fact[n], MOD - 2, MOD)
		for i in reversed(range(n)):
			self.inv_fact[i] = self.inv_fact[i + 1] * (i + 1) % MOD
		self.MOD = MOD

	def inverse(self, k):
		return self.inv_fact[k] * self.fact[k - 1] % self.MOD

	def factorial(self, k):
		return self.fact[k]

	def inverse_factorial(self, k):
		return self.inv_fact[k]

	def permutation(self, k, r):
		if k < r:
			return 0
		return self.fact[k] * self.inv_fact[k - r] % self.MOD

	def combination(self, k, r):
		if k < r:
			return 0
		return self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r] % self.MOD
_T_ = 1
MOD = 998244353
for _t_ in range(_T_):
	(n, k) = inar()
	events = []
	for i in range(n):
		(l, r) = inar()
		events.append(2 * l + 0)
		events.append(2 * r + 1)
	events.sort()
	lighted_candles = 0
	ans = 0
	C = Combination(4 * 10 ** 5, MOD)
	for ev in events:
		if ev & 1 == 0:
			lighted_candles += 1
			ans += C.combination(lighted_candles - 1, k - 1)
			ans %= MOD
		else:
			lighted_candles -= 1
	print(ans)


import sys
input = sys.stdin.readline
MOD = 998244353
N = 3 * 10 ** 5 + 10
fact = [0 for _ in range(N)]
invfact = [0 for _ in range(N)]
fact[0] = 1
for i in range(1, N):
	fact[i] = fact[i - 1] * i % MOD
invfact[N - 1] = pow(fact[N - 1], MOD - 2, MOD)
for i in range(N - 2, -1, -1):
	invfact[i] = invfact[i + 1] * (i + 1) % MOD

def nCk(n, k):
	if k < 0 or n < k:
		return 0
	else:
		return fact[n] * invfact[k] * invfact[n - k] % MOD

def main():
	(n, k) = map(int, input().split())
	l_s = []
	r_s = []
	for _ in range(n):
		(l, r) = map(int, input().split())
		l_s.append(l)
		r_s.append(r)
	l_s.sort()
	r_s.sort()
	l_pos = 0
	r_pos = 0
	total = 0
	ans = 0
	while 1:
		if l_s[l_pos] <= r_s[r_pos]:
			total += 1
			l_pos += 1
			if total >= k:
				ans += nCk(total - 1, k - 1)
				ans %= MOD
			if l_pos == n:
				break
		else:
			total -= 1
			r_pos += 1
	print(ans)
main()


import traceback
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
sys.stdin = IOWrapper(sys.stdin)
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
from collections import defaultdict as dfd, Counter, deque
from functools import lru_cache
from itertools import accumulate

def geti():
	return int(input())

def gets():
	return input()

def getil():
	return list(map(int, input().split()))

def getsl():
	return input().split()

def getinps(s):
	inps = s.split()
	m = {'i': geti, 's': gets, 'il': getil, 'sl': getsl}
	if len(inps) == 1:
		return m[s]()
	return [m[k]() for k in inps]

def get2d(nrows, ncols, n=0):
	return [[n] * ncols for r in range(nrows)]

def get_acc(a):
	return list(accumulate(a))

def get_ncr(n, r, mod=10 ** 9 + 7):
	num = den = 1
	r = min(r, n - r)
	for i in range(r):
		num = num * (n - i) % mod
		den = den * (i + 1) % mod
	return num * pow(den, mod - 2, mod) % mod

def get_nc2(n):
	return n * (n - 1) // 2

def get_npr(n, r):
	if n < r:
		return 0
	return math.factorial(n) // math.factorial(r)

def put(a):
	return ' '.join(map(str, a))
inf = float('inf')
mod = 10 ** 9 + 7

def make_ncr_mod(max_n=2 * 10 ** 5, mod=10 ** 9 + 7):
	max_n = min(max_n, mod - 1)
	(fact, inv_fact) = ([0] * (max_n + 1), [0] * (max_n + 1))
	fact[0] = 1
	for i in range(max_n):
		fact[i + 1] = fact[i] * (i + 1) % mod
	inv_fact[-1] = pow(fact[-1], mod - 2, mod)
	for i in reversed(range(max_n)):
		inv_fact[i] = inv_fact[i + 1] * (i + 1) % mod

	def nCr_mod(n, r):
		res = 1
		while n or r:
			(a, b) = (n % mod, r % mod)
			if a < b:
				return 0
			res = res * fact[a] % mod * inv_fact[b] % mod * inv_fact[a - b] % mod
			n //= mod
			r //= mod
		return res
	return nCr_mod

def main():
	(N, k) = getil()
	a = []
	b = []
	for _ in range(N):
		(x, y) = getil()
		a.append(x)
		b.append(y)
	mod = 998244353
	ncr = make_ncr_mod(max_n=3 * 10 ** 5, mod=mod)
	ans = 0
	a.sort()
	b.sort()
	i = j = 0
	cnt = 0
	N = len(a)
	while i < N:
		if a[i] <= b[j]:
			cnt += 1
			i += 1
			ans += ncr(cnt - 1, k - 1)
			ans %= mod
		else:
			cnt -= 1
			j += 1
	return ans
try:
	ans = main()
	ans = str(ans)
	print(ans)
except Exception as e:
	print(e)
	traceback.print_exc()


def COMinit():
	fac[0] = fac[1] = 1
	finv[0] = finv[1] = 1
	inv[1] = 1
	for i in range(2, n + 1):
		fac[i] = fac[i - 1] * i % mod
		inv[i] = mod - inv[mod % i] * (mod // i) % mod
		finv[i] = finv[i - 1] * inv[i] % mod
	return (fac, inv, finv)

def COM(n, k):
	if n < k:
		return 0
	if n < 0 or k < 0:
		return 0
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod
import sys, os, io
input = sys.stdin.readline
mod = 998244353
(n, k) = map(int, input().split())
fac = [0] * (n + 1)
inv = [0] * (n + 1)
finv = [0] * (n + 1)
COMinit()
ans = 0
(L, R) = ([0] * n, [0] * n)
for i in range(n):
	(L[i], R[i]) = map(int, input().split())
compLR = {e: i + 1 for (i, e) in enumerate(sorted(set(L + R)))}
for i in range(n):
	L[i] = compLR[L[i]]
	R[i] = compLR[R[i]]
on = [0] * (n * 2 + 1)
off = [0] * (n * 2 + 2)
for (l, r) in zip(L, R):
	on[l] += 1
	off[r + 1] += 1
cum = 0
for i in range(1, n * 2 + 1):
	cum -= off[i]
	for j in range(1, on[i] + 1):
		old = k - j
		if 0 <= old <= cum:
			ans += COM(cum, old) * COM(on[i], j) % mod
		ans %= mod
	cum += on[i]
print(ans)


from sys import stdin
readline = stdin.readline
MOD = 998244353
MAXN = 300005
fac = [1] * MAXN
for i in range(1, MAXN):
	fac[i] = fac[i - 1] * i % MOD

def C(k, n):
	if k > n or k < 0:
		return 0
	return fac[n] * pow(fac[k] * fac[n - k] % MOD, MOD - 2, MOD) % MOD
(n, k) = map(int, readline().split())
nodes = []
for _ in range(n):
	(l, r) = map(int, readline().split())
	nodes.append(2 * l)
	nodes.append(2 * r + 1)
nodes = sorted(nodes)
sum_lights = 0
ans = 0
for node in nodes:
	if node % 2:
		sum_lights -= 1
		continue
	ans += C(k - 1, sum_lights)
	ans %= MOD
	sum_lights += 1
print(ans)


import bisect
import array
import functools
import math
input = __import__('sys').stdin.readline
mo = 998244353
fac = array.array('i', [0 for i in range(300005)])
inv = array.array('i', [0 for i in range(300005)])

def init():
	fac[0] = inv[0] = inv[1] = 1
	for i in range(2, 300005):
		inv[i] = inv[mo % i] * (mo - mo // i) % mo
	for i in range(1, 300005):
		fac[i] = fac[i - 1] * i % mo
		inv[i] = inv[i - 1] * inv[i] % mo

def C(n, m):
	if n < 0 or m < 0 or m > n:
		return 0
	return fac[n] * inv[m] * inv[n - m] % mo
(n, k) = map(int, input().split())
a = array.array('i', [0 for i in range(n)])
b = array.array('i', [0 for i in range(n)])
init()
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
a = sorted(a)
b = sorted(b)
ans = 0
(p, s) = (0, 0)
for i in range(n):
	while b[p] < a[i]:
		p = p + 1
		s = s - 1
	ans = ans + C(s, k - 1)
	s = s + 1
print(ans % mo)


mod = 998244353
import sys
input = sys.stdin.readline

def calc(n, r):
	return fact[n] * pow(fact[r] * fact[n - r] % mod, mod - 2, mod) % mod
fact = [1, 1]
for i in range(2, 4 * 10 ** 5):
	fact.append(fact[-1] * i % mod)
(n, k) = map(int, input().split())
(s, e) = ([], [])
(ds, de) = ({}, {})
for i in range(n):
	(l, r) = map(int, input().split())
	s.append(l)
	e.append(r)
	if l in ds:
		ds[l] += 1
	else:
		ds[l] = 1
	if r in de:
		de[r] += 1
	else:
		de[r] = 1
s.sort()
e.sort()
(i, j) = (0, 0)
count = 0
ans = 0
while j < n:
	if i < n and s[i] <= e[j]:
		count += 1
		i += 1
		if count >= k:
			ans += calc(count - 1, k - 1)
			ans = ans % mod
	else:
		count -= 1
		j += 1
print(ans)


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write('\n'.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
from decimal import Decimal
mod = 998244353
INF = float('inf')

def modularInverse_n(n):
	finv = [0] * (n + 1)
	finv[-1] = pow(f[n], mod - 2, mod)
	for i in range(n - 1, -1, -1):
		finv[i] = finv[i + 1] * (i + 1) % mod
	return finv
(n, k) = mdata()
q = sorted([mdata() for i in range(n)], key=lambda x: x[0])
if k == 1:
	out(n)
	exit()
lis = []
f = [1]
for i in range(1, n + 1):
	f.append(i * f[-1] % mod)
finv = [0] * (n + 1)
finv[-1] = pow(f[n], mod - 2, mod)
for i in range(n - 1, -1, -1):
	finv[i] = finv[i + 1] * (i + 1) % mod
heappush(lis, q[0][1])
ans = 0
for i in range(1, n):
	while lis and lis[0] < q[i][0]:
		heappop(lis)
	if len(lis) >= k - 1:
		ans = (ans + f[len(lis)] * finv[k - 1] * finv[len(lis) - k + 1]) % mod
	heappush(lis, q[i][1])
out(ans)


from sys import stdin
import math
input = stdin.readline
m = 998244353

def put():
	return map(int, input().split())

def inv(a, b):
	return pow(b, m - 2, m) * (a % m) % m
(n, k) = put()
C = [0] * (n + 1)
C[k - 1] = 1
for i in range(k, n + 1):
	C[i] = inv(C[i - 1] * i, i - k + 1)
(l, r) = ([], [])
for _ in range(n):
	(a, b) = put()
	l.append(a)
	r.append(b)
l.sort()
r.sort()
(i, j) = (0, 0)
count = 0
ans = 0
while i < n and j < n:
	if l[i] <= r[j]:
		ans += C[count]
		ans %= m
		count += 1
		i += 1
	else:
		count -= 1
		j += 1
print(ans)


import sys
input = sys.stdin.readline
N = 300001
factorialNumInverse = [None] * (N + 1)
naturalNumInverse = [None] * (N + 1)
fact = [None] * (N + 1)

def InverseofNumber(p):
	naturalNumInverse[0] = naturalNumInverse[1] = 1
	for i in range(2, N + 1, 1):
		naturalNumInverse[i] = naturalNumInverse[p % i] * (p - int(p / i)) % p

def InverseofFactorial(p):
	factorialNumInverse[0] = factorialNumInverse[1] = 1
	for i in range(2, N + 1, 1):
		factorialNumInverse[i] = naturalNumInverse[i] * factorialNumInverse[i - 1] % p

def factorial(p):
	fact[0] = 1
	for i in range(1, N + 1):
		fact[i] = fact[i - 1] * i % p

def Binomial(N, R, p):
	if N < R:
		ans = 0
	else:
		ans = fact[N] * factorialNumInverse[R] % p * factorialNumInverse[N - R] % p
	return ans
p = 998244353
InverseofNumber(p)
InverseofFactorial(p)
factorial(p)
(n, k) = map(int, input().split())
init = []
final = []
for _ in range(n):
	(li, ri) = map(int, input().split())
	init.append(li)
	final.append(ri)
init.sort()
final.sort()
i = 0
j = 0
ans = 0
while i < n:
	while final[j] < init[i]:
		j += 1
	if i - j + 1 >= k:
		ans += Binomial(i - j, k - 1, p)
	i += 1
print(ans % p)


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, k) = map(int, input().split())
MOD = 998244353

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, y, x) = egcd(b % a, a)
		return (g, x - b // a * y, y)

def modinv(a, m):
	(g, x, y) = egcd(a, m)
	if g != 1:
		raise Exception('modular inverse does not exist')
	else:
		return x % m
combinationList = []

def combination(n, k, MOD):
	ans = 1
	combinationList.append(ans)
	for i in range(1, n - k + 1):
		ans *= k + i
		ans %= MOD
		ans *= modinv(i, MOD)
		ans %= MOD
		combinationList.append(ans)
query = []
for i in range(n):
	(l, r) = map(int, input().split())
	query.append(l * 3 + 1)
	query.append(r * 3 + 2)
query.sort()
combination(n, k - 1, MOD)
cnt = 0
ans = 0
for elem in query:
	if elem % 3 == 1:
		if cnt >= k - 1:
			ans += combinationList[cnt - k + 1]
			ans %= MOD
		cnt += 1
	else:
		cnt -= 1
print(ans % MOD)


import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
MOD = 998244353
MAX = 5 * 10 ** 5 + 5
fact = [1]
for i in range(1, MAX + 1):
	new = fact[-1] * i
	fact.append(new % MOD)
invL = pow(fact[MAX], MOD - 2, MOD)
factInv = [invL] * (MAX + 1)
for i in range(MAX - 1, -1, -1):
	old = factInv[i + 1]
	new = old * (i + 1)
	factInv[i] = new % MOD

def choose(a, b):
	if a < b:
		return 0
	res = fact[a]
	res *= factInv[b]
	res %= MOD
	res *= factInv[a - b]
	res %= MOD
	return res
(n, k) = map(int, input().split())
events = []
for i in range(n):
	(s, e) = map(int, input().split())
	events.append(2 * s + 0)
	events.append(2 * e + 1)
events.sort()
count = 0
out = 0
for t in events:
	if t & 1 == 0:
		out += choose(count, k - 1)
		count += 1
		out %= MOD
	else:
		count -= 1
print(out)


from sys import stdin
from math import factorial
mod = 998244353
(n, k) = map(int, stdin.readline().split())
start = []
end = []
f = [1] * (n + 1)
inf = [1] * (n + 1)
for i in range(2, n + 1):
	f[i] = i * f[i - 1] % mod
inf[n] = pow(f[n], mod - 2, mod)
for i in range(n - 1, 1, -1):
	inf[i] = (i + 1) * inf[i + 1] % mod
comb = lambda x, y: f[x] * inf[y] * inf[x - y] % mod if x >= y else 0
for _ in range(n):
	(l, r) = map(int, stdin.readline().split())
	start.append(l)
	end.append(r)
total = [2 * i for i in start] + [2 * i + 1 for i in end]
total.sort()
cur = 0
ans = 0
for i in total:
	if i % 2 == 1:
		cur -= 1
		cur %= mod
	else:
		ans += comb(cur, k - 1) % mod
		cur += 1
		cur %= mod
		ans %= mod
print(ans % mod)


from bisect import *
from collections import *
from math import gcd, ceil, sqrt, floor, inf
from heapq import *
from typing import List
from itertools import *
from operator import add, mul, sub, xor, truediv, floordiv
from functools import *
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())
farr = [1]
ifa = []

def fact(x, mod=0):
	if mod:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr) % mod)
	else:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr))
	return farr[x]

def ifact(x, mod):
	global ifa
	ifa.append(inverse(farr[-1], mod))
	for i in range(x, 0, -1):
		ifa.append(ifa[-1] * i % mod)
	ifa = ifa[::-1]

def per(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return fact(i) // fact(i - j)
	return farr[i] * ifa[i - j] % mod

def com(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return per(i, j) // fact(j)
	return per(i, j, mod) * ifa[j] % mod

def catalan(n):
	return com(2 * n, n) // (n + 1)

def linc(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t > f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rinc(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t < f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def ldec(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t < f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rdec(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t > f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def binfun(x):
	c = 0
	for w in arr:
		c += ceil(w / x)
	return c

def lowbit(n):
	return n & -n

def inverse(a, m):
	a %= m
	if a <= 1:
		return a
	return (1 - inverse(m, a) * m) // a % m

class BIT:

	def __init__(self, arr):
		self.arr = arr
		self.n = len(arr) - 1

	def update(self, x, v):
		while x <= self.n:
			self.arr[x] += v
			x += x & -x

	def query(self, x):
		ans = 0
		while x:
			ans += self.arr[x]
			x &= x - 1
		return ans

class smt:

	def __init__(self, l, r, arr):
		self.l = l
		self.r = r
		self.value = (1 << 31) - 1 if l < r else arr[l]
		mid = (l + r) // 2
		if l < r:
			self.left = smt(l, mid, arr)
			self.right = smt(mid + 1, r, arr)
			self.value &= self.left.value & self.right.value

	def setvalue(self, x, val):
		if self.l == self.r:
			self.value = val
			return
		mid = (self.l + self.r) // 2
		if x <= mid:
			self.left.setvalue(x, val)
		else:
			self.right.setvalue(x, val)
		self.value = self.left.value & self.right.value

	def ask(self, l, r):
		if l <= self.l and r >= self.r:
			return self.value
		val = (1 << 31) - 1
		mid = (self.l + self.r) // 2
		if l <= mid:
			val &= self.left.ask(l, r)
		if r > mid:
			val &= self.right.ask(l, r)
		return val

class DSU:

	def __init__(self, n):
		self.c = [-1] * n

	def same(self, x, y):
		return self.find(x) == self.find(y)

	def find(self, x):
		if self.c[x] < 0:
			return x
		self.c[x] = self.find(self.c[x])
		return self.c[x]

	def union(self, u, v):
		(u, v) = (self.find(u), self.find(v))
		if u == v:
			return False
		if self.c[u] < self.c[v]:
			(u, v) = (v, u)
		self.c[u] += self.c[v]
		self.c[v] = u
		return True

	def size(self, x):
		return -self.c[self.find(x)]

class UFS:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(pu, pv) = (self.find(u), self.find(v))
		if pu == pv:
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv

def Prime(n):
	c = 0
	prime = []
	flag = [0] * (n + 1)
	for i in range(2, n + 1):
		if not flag[i]:
			prime.append(i)
			c += 1
		for j in range(c):
			if i * prime[j] > n:
				break
			flag[i * prime[j]] = prime[j]
			if i % prime[j] == 0:
				break
	return prime

def dij(s, graph):
	d = {}
	d[s] = 0
	heap = [(0, s)]
	seen = set()
	while heap:
		(dis, u) = heappop(heap)
		if u in seen:
			continue
		for v in graph[u]:
			if v not in d or d[v] > d[u] + graph[u][v]:
				d[v] = d[u] + graph[u][v]
				heappush(heap, (d[v], v))
	return d
t = 1
for i in range(t):
	(n, k) = RL()
	M = 998244353
	s = []
	e = []
	v = [1]
	v2 = []
	for i in range(1, n + 1):
		v.append(v[-1] * i % M)
	v2.append(pow(v[-1], M - 2, M))
	for i in range(n):
		v2.append(v2[-1] * (n - i) % M)
	v2 = v2[::-1]
	for i in range(n):
		(a, b) = RL()
		s.append(a)
		e.append(b)
	s.sort()
	e.sort()
	s.append(2 * M)
	e.append(2 * M)
	si = ei = t = r = 0
	while si + ei < n + n:
		while si < n and s[si] <= e[ei]:
			si += 1
			t += 1
		while ei < n and e[ei] < s[si]:
			ei += 1
			t -= 1
			if t >= k - 1:
				r = (r + v[t] * v2[k - 1] % M * v2[t - k + 1]) % M
	print(r)


from sys import stdin
mod = 998244353

def inv(a, b):
	return a % mod * pow(b, mod - 2, mod) % mod
(n, k) = map(int, input().split())
C = [0] * (n + 1)
C[k - 1] = 1
for i in range(k, n + 1):
	C[i] = inv(C[i - 1] * i % mod, i - k + 1)
(l, r) = ([], [])
for i in range(n):
	(a, b) = map(int, stdin.readline().split())
	l.append(a)
	r.append(b)
l.sort()
r.sort()
(i, j) = (0, 0)
(num, ans) = (0, 0)
while i < n and j < n:
	if l[i] <= r[j]:
		ans += C[num]
		num += 1
		i += 1
	else:
		num -= 1
		j += 1
print(ans % mod)


import sys
import math
input = sys.stdin.readline
(n, q) = list(map(int, input().split()))
pre = {}
pre[0] = 1
pre[1] = 1
mod = 998244353

def ncr(n, r, p, pre):
	num = pre[n]
	den = pre[r] * pre[n - r]
	den = den % p
	return num * pow(den, p - 2, p) % p
for i in range(1 + 1, n + 1):
	pre[i] = pre[i - 1] * i
	pre[i] = pre[i] % mod
precalc = {}
ll = []
rr = []
aa = []
for _ in range(n):
	(l, r) = list(map(int, input().split()))
	ll.append(l)
	rr.append(r)
	aa.append(l)
	aa.append(r)
ll.sort()
rr.sort()
aa.sort()
i = 0
j = 0
open = 0
last = 0
total = 0
for num in aa:
	kb = 0
	while i < len(ll) and num == ll[i]:
		i += 1
		open += 1
		kb += 1
	if kb > 0:
		if open >= q:
			last = open - kb
			if last < q:
				cr = 0
			elif (last, q) not in precalc:
				cr = ncr(last, q, mod, pre)
				precalc[last, q] = cr
			else:
				cr = precalc[last, q]
			if (open, q) not in precalc:
				br = ncr(open, q, mod, pre)
				precalc[open, q] = br
			else:
				br = precalc[open, q]
			total += br - cr
	while j < len(rr) and num == rr[j]:
		j += 1
		open -= 1
total = total % mod
print(total)


import os
import sys
from io import BytesIO, IOBase
_str = str
BUFSIZE = 8192

def str(x=b''):
	return x if type(x) is bytes else _str(x).encode()

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def inp():
	return sys.stdin.readline()

def mpint():
	return map(int, sys.stdin.readline().split(' '))

def itg():
	return int(sys.stdin.readline())
MOD = 998244353

def make_nCr_mod(max_n=2 * 10 ** 5, mod=10 ** 9 + 7):
	max_n = min(max_n, mod - 1)
	(fact, inv_fact) = ([0] * (max_n + 1), [0] * (max_n + 1))
	fact[0] = 1
	for i in range(max_n):
		fact[i + 1] = fact[i] * (i + 1) % mod
	inv_fact[-1] = pow(fact[-1], mod - 2, mod)
	for i in reversed(range(max_n)):
		inv_fact[i] = inv_fact[i + 1] * (i + 1) % mod

	def nCr_mod(n, r):
		res = 1
		while n or r:
			(a, b) = (n % mod, r % mod)
			if a < b:
				return 0
			res = res * fact[a] % mod * inv_fact[b] % mod * inv_fact[a - b] % mod
			n //= mod
			r //= mod
		return res
	return nCr_mod
nCr = make_nCr_mod(int(300000.0), 998244353)

def solve():
	(n, k) = mpint()
	intervals = []
	for _ in range(n):
		(a, b) = mpint()
		intervals.append((a, 1))
		intervals.append((b, -1))
	intervals.sort(key=lambda p: p[0] * (n + 87) - p[1])
	ans = count = 0
	for (idx, v) in intervals:
		count += v
		if v == 1:
			ans += nCr(count - 1, k - 1)
	print(ans % MOD)
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
solve()


import math
m = 998244353
(n, k) = map(int, input().split())
fact = [1]
for i in range(1, n + 1):
	fact.append(fact[-1] * i % m)
ifactn = pow(fact[-1], m - 2, m)
ifact = [ifactn] * (n + 1)
for i in range(n - 1, -1, -1):
	ifact[i] = ifact[i + 1] * (i + 1) % m
choose = []
for i in range(k - 1, n + 1):
	choose.append(fact[i] * ifact[k - 1] % m * ifact[i - k + 1] % m)
event = []
for i in range(n):
	inp = input().split()
	event.append(int(inp[0]) * 2)
	event.append(int(inp[1]) * 2 + 1)
event.sort()
val = 0
curr = 0
for e in event:
	if e % 2 == 0:
		curr += 1
	else:
		if curr >= k:
			val = (val + choose[curr - k]) % m
		curr -= 1
print(val)


from collections import Counter
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def bucketsort(order, seq):
	buckets = [0] * (max(seq) + 1)
	for x in seq:
		buckets[x] += 1
	for i in range(len(buckets) - 1):
		buckets[i + 1] += buckets[i]
	new_order = [-1] * len(seq)
	for i in reversed(order):
		x = seq[i]
		idx = buckets[x] = buckets[x] - 1
		new_order[idx] = i
	return new_order

def ordersort(order, seq, reverse=False):
	bit = max(seq).bit_length() >> 1
	mask = (1 << bit) - 1
	order = bucketsort(order, [x & mask for x in seq])
	order = bucketsort(order, [x >> bit for x in seq])
	if reverse:
		order.reverse()
	return order

def long_ordersort(order, seq):
	order = ordersort(order, [int(i & 2147483647) for i in seq])
	return ordersort(order, [int(i >> 31) for i in seq])

def multikey_ordersort(order, *seqs, sort=ordersort):
	for i in reversed(range(len(seqs))):
		order = sort(order, seqs[i])
	return order
(n, k) = map(int, input().split())
left = []
right = []
for _ in range(n):
	(l, r) = map(int, input().split())
	left.append(l)
	right.append(10)
	left.append(r + 1)
	right.append(1)
temp = multikey_ordersort(range(2 * n), left, right)
timeline = [(left[i], right[i]) for i in temp]
mod = 998244353
N = 3 * (10 ** 5 + 1)
factorialNumInverse = [None] * (N + 1)
naturalNumInverse = [None] * (N + 1)
fact = [None] * (N + 1)

def InverseofNumber(p):
	naturalNumInverse[0] = naturalNumInverse[1] = 1
	for i in range(2, N + 1, 1):
		naturalNumInverse[i] = naturalNumInverse[p % i] * (p - int(p / i)) % p

def InverseofFactorial(p):
	factorialNumInverse[0] = factorialNumInverse[1] = 1
	for i in range(2, N + 1, 1):
		factorialNumInverse[i] = naturalNumInverse[i] * factorialNumInverse[i - 1] % p

def factorial(p):
	fact[0] = 1
	for i in range(1, N + 1):
		fact[i] = fact[i - 1] * i % p

def Binomial(N, R, p):
	ans = fact[N] * factorialNumInverse[R] % p * factorialNumInverse[N - R] % p
	return ans
p = 998244353
InverseofNumber(p)
InverseofFactorial(p)
factorial(p)
curr = 0
ans = 0
for (a, b) in timeline:
	if b == 1:
		curr -= 1
	else:
		if curr >= k - 1:
			ans += Binomial(curr, k - 1, mod)
		curr += 1
print(ans % mod)


import sys
input = sys.stdin.readline
(N, K) = map(int, input().split())
LR = [tuple(map(int, input().split())) for i in range(N)]
MOD = 998244353
MAXN = N + 5
fac = [1, 1] + [0] * MAXN
finv = [1, 1] + [0] * MAXN
inv = [0, 1] + [0] * MAXN
for i in range(2, MAXN + 2):
	fac[i] = fac[i - 1] * i % MOD
	inv[i] = -inv[MOD % i] * (MOD // i) % MOD
	finv[i] = finv[i - 1] * inv[i] % MOD

def comb(n, r):
	if n < r:
		return 0
	if n < 0 or r < 0:
		return 0
	return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD
arr = []
for (l, r) in LR:
	arr.append(l * 2)
	arr.append(r * 2 + 1)
arr.sort()
ans = 0
sz = 0
for e in arr:
	if e % 2:
		sz -= 1
	else:
		if sz + 1 >= K:
			ans += comb(sz, K - 1)
			ans %= MOD
		sz += 1
print(ans)


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
mod = 998244353

def factorial(n):
	fact = [i for i in range(n + 1)]
	fact[0] = 1
	for i in range(3, n + 1):
		fact[i] = fact[i] * fact[i - 1] % mod
	return fact

def invfac(n, factmax):
	m = pow(factmax, mod - 2, mod)
	invf = [m for i in range(n + 1)]
	for i in range(n - 1, -1, -1):
		invf[i] = invf[i + 1] * (i + 1) % mod
	return invf

def comb(a, b):
	if b > a:
		return 0
	elif b == a:
		return 1
	else:
		return factn[a] * invfactn[b] % mod * invfactn[a - b] % mod
(n, k) = list(map(int, input().split()))
factn = factorial(n)
invfactn = invfac(n, factn[-1])
lrl = []
maxt = 0
for i in range(n):
	(l, r) = list(map(int, input().split()))
	(lrl.append(2 * l),)
	lrl.append(2 * r + 1)
lrl = sorted(lrl)
s = 0
c = 0
for i in lrl:
	if i & 1 == 0:
		s += comb(c, k - 1)
		s %= mod
		c += 1
	else:
		c -= 1
print(s)


import sys
import math
mod = 998244353
inf = float('inf')
from collections import defaultdict

def I():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

class BinaryIndexedTree:

	def __init__(self, size):
		self.bit = [0 for _ in range(size)]
		self.size = size

	def add(self, i, w):
		x = i + 1
		while x <= self.size:
			self.bit[x - 1] += w
			x += x & -x
		return

	def sum(self, i):
		res = 0
		x = i + 1
		while x > 0:
			res += self.bit[x - 1]
			x -= x & -x
		return res

def comb(n, r):
	return fact[n] * inv[n - r] * inv[r] % mod
(n, k) = LI()
lr = [LI() for _ in range(n)]
fact = [1] * (n + 1)
inv = [1] * (n + 1)
for i in range(1, n + 1):
	fact[i] = i * fact[i - 1]
	fact[i] %= mod
	inv[i] = pow(i, mod - 2, mod) * pow(fact[i - 1], mod - 2, mod)
	inv[i] %= mod
lst = []
for (l, r) in lr:
	lst.append(2 * l)
	lst.append(2 * r + 1)
lst.sort()
tmp = 0
ans = 0
for i in lst:
	if i % 2:
		tmp -= 1
	else:
		if tmp >= k - 1:
			ans += comb(tmp, k - 1)
			ans %= mod
		tmp += 1
print(ans)


from math import factorial as f
from heapq import heappush, heappop
import sys

def inp():
	return sys.stdin.buffer.readline().rstrip()

def inpa():
	return tuple(map(int, inp().split()))

def out(var):
	sys.stdout.write(str(var) + '\n')

def outa(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def setup():
	import os, sys
	dir_path = os.path.dirname(os.path.realpath(__file__))
	sys.stdin = open(os.path.join(dir_path, 'input.txt'), 'r')
	sys.stdout = open(os.path.join(dir_path, 'output.txt'), 'w')

def C(n, k):
	return fac[n] * invf[n - k] * invf[k] % mod if n >= k else 0
MAXN = 3 * 10 ** 5
mod = 998244353
fac = [1]
for i in range(1, MAXN + 1):
	fac.append(fac[-1] * i % mod)
invf = [pow(fac[-1], mod - 2, mod)]
for i in range(MAXN, 0, -1):
	invf.append(i * invf[-1] % mod)
invf = invf[::-1]

def solve(arr, size, k):
	a = [i[0] for i in arr]
	a.extend([i[1] for i in arr])
	times = sorted(set(a))
	arr.sort(key=lambda x: x[0])
	ans = idx = 0
	h = []
	for time in times:
		while idx < size and arr[idx][0] == time:
			heappush(h, arr[idx][1])
			idx += 1
		if h[0] != time:
			continue
		(m, n) = (len(h), 0)
		while h and h[0] == time:
			heappop(h)
			n += 1
		m -= n
		if m + n >= k:
			ans += (C(m + n, k) - C(m, k)) % mod
	return ans % mod
(n, k) = inpa()
arr = [inpa() for _ in range(n)]
out(solve(arr, n, k))


import sys
import math
import collections
import bisect
import itertools
import decimal
import copy
import heapq
INF = 10 ** 20
MOD = 998244353
ni = lambda : int(sys.stdin.buffer.readline())
ns = lambda : map(int, sys.stdin.buffer.readline().split())
na = lambda : list(map(int, sys.stdin.buffer.readline().split()))
na1 = lambda : list(map(lambda x: int(x) - 1, sys.stdin.buffer.readline().split()))
flush = lambda : sys.stdout.flush()

def main():

	def prepare(n, MOD):
		f = 1
		factorials = [1]
		for m in range(1, n + 1):
			f *= m
			f %= MOD
			factorials.append(f)
		inv = pow(f, MOD - 2, MOD)
		invs = [1] * (n + 1)
		invs[n] = inv
		for m in range(n, 1, -1):
			inv *= m
			inv %= MOD
			invs[m - 1] = inv
		return (factorials, invs)
	(n, k) = ns()
	(facts, invs) = prepare(n, MOD)
	items = [na() for _ in range(n)]
	items.sort()
	ans = 0
	hq = []
	for (l, r) in items:
		heapq.heappush(hq, r)
		while hq and hq[0] < l:
			heapq.heappop(hq)
		total = len(hq)
		if total >= k:
			ans += facts[total - 1] * invs[k - 1] * invs[total - 1 - (k - 1)] % MOD
			ans %= MOD
	print(ans)
main()


import sys
import array
input = lambda : sys.stdin.readline()

def getint():
	return int(input())

def getints():
	return map(int, input().split())

def getlistints():
	return list(map(int, input().split()))
fac = array.array('i', [0 for _ in range(300003)])
inv = array.array('i', [1 for _ in range(300003)])
mod = 998244353

def init():
	fac[0] = 1
	for i in range(2, 300003):
		inv[i] = inv[mod % i] * (mod - mod // i) % mod
	for i in range(1, 300003):
		fac[i] = fac[i - 1] * i % mod
		inv[i] = inv[i - 1] * inv[i] % mod
	return

def comb(n, m):
	if m < 0 or n < 0 or n < m:
		return 0
	return fac[n] * inv[m] * inv[n - m] % mod
init()
(n, k) = getints()
start = array.array('i', [0 for _ in range(n)])
end = array.array('i', [0 for _ in range(n)])
for i in range(n):
	(start[i], end[i]) = getints()
start = sorted(start)
end = sorted(end)
res = 0
(j, cnt) = (0, 0)
for i in range(n):
	while end[j] < start[i]:
		j += 1
		cnt -= 1
	res += comb(cnt, k - 1)
	cnt += 1
print(res % mod)


import sys
import io, os
input = sys.stdin.readline
(n, k) = list(map(int, input().split()))
ranges = []
mod = 998244353
den = 1
num = 1
for i in range(k - 1):
	den = den * (i + 1) % mod
	num = num * (k - i) % mod
dp = {}
dp[0] = 1
divisor = 1
for j in range(1, n + 1):
	dp[j] = dp[j - 1] % mod * j % mod
	divisor += 1
for _ in range(n):
	(l, r) = list(map(int, input().split()))
	ranges.append(l * 2)
	ranges.append(r * 2 + 1)
ranges.sort()
cnt = 0
total = 0
for i in range(0, len(ranges)):
	if ranges[i] % 2 == 0:
		if cnt >= k - 1:
			total = (total + dp[cnt] * pow(dp[k - 1] * dp[cnt - (k - 1)] % mod, mod - 2, mod)) % mod
		cnt += 1
	else:
		cnt -= 1
print(total % mod)


from sys import stdin, stdout
(n, k) = list(map(int, stdin.readline().split()))
fact = [1]
lim = n + 5
M = 998244353

def modexp(a, b, M):
	ans = 1
	while b > 0:
		if b & 1:
			ans = ans * a % M
		b = b >> 1
		a = a * a % M
	return ans
for i in range(1, lim + 1):
	fact += [fact[-1] * i % M]

def Invfact(num):
	return modexp(num, M - 2, M)

def nCr(n1, r1):
	num = fact[n1]
	den = Invfact(fact[r1])
	result = num * den % M
	den = Invfact(fact[n1 - r1])
	result = result * den % M
	return result
for _ in range(1):
	arr = []
	ans = cnt = 0
	dep = []
	for i in range(n):
		(aa, dd) = list(map(int, stdin.readline().split()))
		arr += [aa]
		dep += [dd]
	arr.sort()
	dep.sort()
	aa = dd = 0
	while aa < n and dd < n:
		if arr[aa] <= dep[dd]:
			cnt += 1
			if cnt >= k:
				ans = (ans + nCr(cnt - 1, k - 1)) % M
			aa += 1
		else:
			cnt -= 1
			dd += 1
	print(ans)


import sys
MOD = 998244353
input = sys.stdin.readline
(n, k) = map(int, input().split(' '))
fact = [None for i in range(n + 1)]

def C(n, k):
	if k > n or k < 0:
		return 0
	return fact[n] * pow(fact[k] * fact[n - k], MOD - 2, MOD) % MOD
fact[0] = 1
for i in range(1, n + 1):
	fact[i] = fact[i - 1] * i % MOD
starts = []
ends = []
for i in range(n):
	(l, r) = map(int, input().split(' '))
	starts.append(l)
	ends.append(r)
starts.sort()
ends.sort()
i = 0
j = 0
ans = 0
on_lamps = 0
while i < n or j < n:
	if i != n and starts[i] <= ends[j]:
		on_lamps += 1
		i += 1
		ans += C(on_lamps - 1, k - 1)
		ans %= MOD
	else:
		on_lamps -= 1
		j += 1
print(ans)


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write('\n'.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
from decimal import Decimal
mod = 998244353
INF = float('inf')

def make_nCr_mod(max_n, mod):
	max_n = min(max_n, mod - 1)
	(fact, inv_fact) = ([0] * (max_n + 1), [0] * (max_n + 1))
	fact[0] = 1
	for i in range(max_n):
		fact[i + 1] = fact[i] * (i + 1) % mod
	inv_fact[-1] = pow(fact[-1], mod - 2, mod)
	for i in reversed(range(max_n)):
		inv_fact[i] = inv_fact[i + 1] * (i + 1) % mod

	def nCr_mod(n, r):
		res = 1
		while n or r:
			(a, b) = (n % mod, r % mod)
			if a < b:
				return 0
			res = res * fact[a] % mod * inv_fact[b] % mod * inv_fact[a - b] % mod
			n //= mod
			r //= mod
		return res
	return nCr_mod
(n, k) = mdata()
q = sorted([mdata() for i in range(n)], key=lambda x: x[0])
lis = []
if k == 1:
	out(n)
	exit()
f = [1]
for i in range(1, n + 1):
	f.append(i * f[-1] % mod)
p = pow(f[k - 1], mod - 2, mod)
heappush(lis, q[0][1])
ans = 0
C = make_nCr_mod(n, mod)
for i in range(1, n):
	while lis and lis[0] < q[i][0]:
		heappop(lis)
	if len(lis) >= k - 1:
		ans = (ans + C(len(lis), k - 1)) % mod
	heappush(lis, q[i][1])
out(ans)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil, pi, sin, cos, acos, atan
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
from itertools import permutations, combinations
mod = int(1000000000.0) + 7
mod2 = 998244353
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')

def ncr(n, r, p):
	num = fac[n]
	den = fac[r] * fac[n - r] % p
	return num * pow(den, p - 2, p) % p
const = 300001
fac = [0] * const
fac[0] = 1
cal = 1
for i in range(1, const):
	cal = cal * i % mod2
	fac[i] = cal
t = 1
for _ in range(t):
	(n, k) = inp()
	request = []
	for i in range(n):
		(l, r) = inp()
		request.append(2 * l)
		request.append(2 * r + 1)
	request.sort()
	cur = 0
	ans = 0
	for i in request:
		if i & 1 == 0:
			if cur >= k - 1:
				ans += ncr(cur, k - 1, mod2)
				ans %= mod2
			cur += 1
		else:
			cur -= 1
	out(ans)


from sys import stdin
input = stdin.readline
mod = 998244353
maxN = 3 * 10 ** 5 + 9
f = [1] * maxN
for i in range(2, maxN):
	f[i] = f[i - 1] * i % mod
sc = []
(n, k) = map(int, input().split())
for _ in range(n):
	(l, r) = map(int, input().split())
	sc.append(l * 2)
	sc.append(r * 2 + 1)
cnt = ans = 0
for i in sorted(sc):
	if i % 2:
		cnt -= 1
	else:
		if k - 1 <= cnt:
			ans = (ans + f[cnt] * pow(f[k - 1] * f[cnt - (k - 1)] % mod, mod - 2, mod) % mod) % mod
		cnt += 1
print(ans)


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def powerMo(a, n, mo):
	ans = 1
	posi = a
	while n > 0:
		if n & 1:
			ans *= posi
			ans %= mo
		n >>= 1
		posi = posi * posi % mo
	return ans

def modInv(a, mo):
	return powerMo(a, mo - 2, mo)
mo = 998244353

def f():
	(n, k) = [int(s) for s in input().split()]
	comb = [0] * (n + 1)
	comb[k] = 1
	for m in range(k + 1, n + 1):
		comb[m] = comb[m - 1] * (m - 1) * modInv(m - k, mo) % mo
	on = []
	off = []
	for _ in range(n):
		(x, y) = [int(s) for s in input().split()]
		on.append(x)
		off.append(y)
	on.sort()
	off.sort()
	ans = 0
	count = 0
	i = 0
	j = 0
	while i < n and j < n:
		if on[i] <= off[j]:
			i += 1
			count += 1
			ans += comb[count]
		else:
			j += 1
			count -= 1
	print(ans % mo)
f()


from sys import stdin, stdout
from math import gcd, sqrt, factorial, pi, inf
from collections import deque, defaultdict
from bisect import bisect, bisect_left
from time import time
from itertools import permutations as per
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\r\n')
L = lambda : list(R())
P = lambda x: stdout.write(str(x) + '\n')
lcm = lambda x, y: x * y // gcd(x, y)
nCr = lambda x, y: f[x] * inv(f[y] * f[x - y] % N) % N
inv = lambda x: pow(x, N - 2, N)
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
N = 998244353
f = [1]
for i in range(1, int(300000.0) + 5):
	f += (f[-1] * i % N,)
(n, k) = R()
a = []
for i in range(n):
	(x, y) = R()
	a.extend([x * 2, y * 2 + 1])
a.sort()
ans = 0
cnt = 0
for i in a:
	if i % 2:
		cnt -= 1
	else:
		if k - 1 <= cnt:
			ans = (ans + nCr(cnt, k - 1)) % N
		cnt += 1
print(ans)


import sys
from array import array
import typing as Tp

def input():
	return sys.stdin.buffer.readline().decode('utf-8')

def output(*args):
	sys.stdout.buffer.write(('\n'.join(map(str, args)) + '\n').encode('utf-8'))

def main():
	from heapq import heappop, heappush
	(n, k) = map(int, input().split())
	mod = 998244353
	max_n = n + 100
	(fac, inv) = (array('i', [1]) * max_n, array('i', [1]) * max_n)
	for i in range(2, max_n):
		fac[i] = fac[i - 1] * i % mod
	inv[-1] = pow(fac[-1], mod - 2, mod)
	for i in range(max_n - 1, 0, -1):
		inv[i - 1] = inv[i] * i % mod
	ans = array('i', [0])
	a = sorted((tuple(map(int, input().split())) for _ in range(n)))
	hq = []
	if k == 1:
		print(n)
		exit()
	for (l, r) in a:
		while hq and hq[0] < l:
			heappop(hq)
		if len(hq) >= k - 1:
			ans[0] += fac[len(hq)] * inv[k - 1] * inv[len(hq) - (k - 1)] % mod
			if ans[0] >= mod:
				ans[0] -= mod
		heappush(hq, r)
	print(ans[0])
main()


from sys import stdin, stdout
input = stdin.readline
print = lambda x: stdout.write(str(x) + '\n')
M = 998244353

def nCr(n, r, M):
	return fact[n] * inv[n - r] % M * inv[r] % M
(n, k) = map(int, input().split())
fact = [1] * (n + 1)
inv = [1] * (n + 1)
for i in range(1, n + 1):
	fact[i] = fact[i - 1] * i % M
inv[n] = pow(fact[n], M - 2, M)
for i in range(n - 1, -1, -1):
	inv[i] = inv[i + 1] * (i + 1) % M
a = []
for _ in range(n):
	(l, r) = map(int, input().split())
	a.append(l + l)
	a.append(r + r + 1)
a.sort()
cnts = 0
c = 0
for i in a:
	if i % 2:
		c -= 1
	else:
		if c >= k - 1:
			cnts += nCr(c, k - 1, M)
		c += 1
print(cnts % M)


import sys
input = sys.stdin.readline
MOD = 998244353
MAX = 5 * 10 ** 5 + 5
fact = [1]
for i in range(1, MAX + 1):
	new = fact[-1] * i
	fact.append(new % MOD)
invL = pow(fact[MAX], MOD - 2, MOD)
factInv = [invL] * (MAX + 1)
for i in range(MAX - 1, -1, -1):
	old = factInv[i + 1]
	new = old * (i + 1)
	factInv[i] = new % MOD

def choose(a, b):
	if a < b:
		return 0
	res = fact[a]
	res *= factInv[b]
	res %= MOD
	res *= factInv[a - b]
	res %= MOD
	return res
(n, k) = list(map(int, input().split()))
events = []
for i in range(n):
	(s, e) = list(map(int, input().split()))
	events.append(2 * s + 0)
	events.append(2 * e + 1)
events.sort()
count = 0
out = 0
for t in events:
	if t & 1 == 0:
		out += choose(count, k - 1)
		count += 1
		out %= MOD
	else:
		count -= 1
print(out)


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
MOD = 998244353
(n, k) = map(int, input().split())
a = [tuple(map(int, input().split())) for _ in range(n)]
fac = [1] * (n + 1)
for i in range(2, n + 1):
	fac[i] = fac[i - 1] * i % MOD
ifac = [1] * (n + 1)
ifac[n] = pow(fac[n], MOD - 2, MOD)
for i in range(n - 1, 1, -1):
	ifac[i] = ifac[i + 1] * (i + 1) % MOD
comb = lambda n, k: fac[n] * ifac[k] % MOD * ifac[n - k] % MOD if 0 <= k <= n else 0
e = [s * 2 for (s, _) in a] + [e * 2 + 1 for (_, e) in a]
e.sort()
cur = ways = 0
for t in e:
	if t % 2:
		cur -= 1
	else:
		ways += comb(cur, k - 1)
		cur += 1
print(ways % MOD)


import sys
import math
from collections import defaultdict, Counter
import heapq
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def power(x, y, m):
	if y == 0:
		return 1
	p = power(x, y // 2, m) % m
	p = p * p % m
	if y % 2 == 0:
		return p
	else:
		return x * p % m
m = 998244353
(n, k) = map(int, input().split())
k1 = k - 1
comb = [0] * (n + 1)
comb[k1] = 1
inv = [0] * (n + 1)
inv[0] = inv[1] = 1
for i in range(2, n + 1):
	inv[i] = inv[m % i] * (m - m // i) % m
for j in range(k1 + 1, n + 1):
	comb[j] = comb[j - 1] * j % m * inv[j - k1] % m
d = []
for i in range(n):
	(l, r) = map(int, input().split())
	d.append((l, r))
d.sort()
s = []
heapq.heapify(s)
ans = 0
for i in range(n):
	while s and s[0] < d[i][0]:
		heapq.heappop(s)
	ans = (ans + comb[len(s)]) % m
	heapq.heappush(s, d[i][1])
print(ans)


import heapq
import sys
input = sys.stdin.readline

class Combination:

	def __init__(self, n, MOD):
		self.fact = [1]
		for i in range(1, n + 1):
			self.fact.append(self.fact[-1] * i % MOD)
		self.inv_fact = [0] * (n + 1)
		self.inv_fact[n] = pow(self.fact[n], MOD - 2, MOD)
		for i in reversed(range(n)):
			self.inv_fact[i] = self.inv_fact[i + 1] * (i + 1) % MOD
		self.MOD = MOD

	def inverse(self, k):
		return self.inv_fact[k] * self.fact[k - 1] % self.MOD

	def factorial(self, k):
		return self.fact[k]

	def inverse_factorial(self, k):
		return self.inv_fact[k]

	def permutation(self, k, r):
		if k < r:
			return 0
		return self.fact[k] * self.inv_fact[k - r] % self.MOD

	def combination(self, k, r):
		if k < r:
			return 0
		return self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r] % self.MOD
mod = 998244353
(n, k) = map(int, input().split())
(heap, store) = ([], [])
comb = Combination(5 * 10 ** 5, mod)
for ii in range(n):
	(l, r) = map(int, input().split())
	store.append((l, r))
store.sort()
ans = 0
for i in range(n):
	heapq.heappush(heap, store[i][1])
	while store[i][0] > heap[0]:
		heapq.heappop(heap)
	if k != 2:
		ans += comb.combination(len(heap) - 1, k - 1)
	else:
		ans += len(heap) - 1
	ans %= mod
sys.stdout.write(str(ans) + '\n')


import sys
input = sys.stdin.buffer.readline
MOD = 998244353
(n, k) = [int(x) for x in input().split()]
start = []
end = []
for _ in range(n):
	(s, e) = [int(x) for x in input().split()]
	start.append(s)
	end.append(e)
start.sort()
end.sort()
nCr = dict()
den = 1
for N in range(k - 1):
	den = den * (N + 1) % MOD
num = den
nCr[k - 1, k - 1] = 1
divisor = 1
for N in range(k, n + 1):
	num = num * N % MOD
	num = num % MOD * pow(divisor, MOD - 2, MOD) % MOD
	nCr[N, k - 1] = num % MOD * pow(den, MOD - 2, MOD) % MOD
	divisor += 1
ans = 0
ei = -1
contains = 0
for si in range(n):
	contains += 1
	while ei < n - 1 and end[ei + 1] < start[si]:
		ei += 1
		contains -= 1
	if contains - 1 >= k - 1:
		ans += nCr[contains - 1, k - 1]
		ans %= MOD
print(ans)