A Train started its journey at x=-infinity is travelling on the x-Coordinate Axis. Given n passengers and the coordinates $b_i$ and $d_i$ for each of the $ith$ passenger at which they board and leave from the train respectively. Due to current COVID-19 crisis, the train is monitored at each mile/coordinate. The infection degree of the train at each mile is equal to the total passengers present in the train at that mile/coordinate. The train stops its journey if no more passengers are there to board the train. The term infection severity of the journey is defined as the sum of infection degrees noted at each mile. Find the Infection severity of the journey. Note: A passenger is considered for calculation of infection degree at both boarding and leaving stations.

Since the answer can be very large, print it modulo $(10^9)+7$.

-----Input:-----
- First line will contain $N$, number of passengers. Then the $N$ lines follow. 
- $i$th line contains two integers $b_i, d_i$ , the boarding and departure mile of $i$th passenger.

-----Output:-----
Print a single value, the Infection Severity of the journey modulo $(10^9)+7$.

-----Constraints-----
- $0 \leq N \leq 100000$
- $-500000 \leq b_i \leq 500000$
- $-500000 \leq d_i \leq 500000$

-----Sample Input:-----
3

0 2

1 3

-1 4  

-----Sample Output:-----
12    

-----EXPLANATION:-----
Infection degree at :

-1 is 1

0 is 2

1 is 3

2 is 3

3 is 2

4 is 1

Calculation started at mile -1 and ended at mile 4. Infection Severity = 1+2+3+3+2+1 =12

Difficulty: UNKNOWN_DIFFICULTY

Starter code:

Solutions:
c = 0
for i in range(int(input())):
	(a, b) = map(int, input().split())
	c += abs(a - b) + 1
print(c % (10 ** 9 + 7))


try:
	n = int(input())
	sm = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		sm += abs(a - b) + 1
	print(sm % 1000000007)
except:
	pass


def add(arr, N, lo, hi, val):
	arr[lo] += val
	if hi != N - 1:
		arr[hi + 1] -= val

def updateArray(arr, N):
	for i in range(1, N):
		arr[i] += arr[i - 1]
n = 1000000
l = [0] * n
for _ in range(int(input())):
	(b, d) = map(int, input().split())
	add(l, n, b + 50000, d + 50000, 1)
updateArray(l, n)
print(sum(l) % 1000000007)


n = int(input())
list1 = []
for i in range(n):
	(b, d) = list(map(int, input().strip().split()))
	if b >= 0 and d <= 0 or (b <= 0 and d >= 0):
		s = abs(b) + abs(d) + 1
		list1.append(s)
	else:
		s = abs(abs(b) - abs(d)) + 1
		list1.append(s)
s = sum(list1)
print(s % 1000000007)


t = int(input())
c = dict()
k = dict()
for _ in range(t):
	(b, d) = list(map(int, input().split()))
	if b not in c:
		c[b] = 1
	else:
		c[b] += 1
	if d not in k:
		k[d] = 1
	else:
		k[d] += 1
ans = 0
count = 0
p = 10 ** 9 + 7
for i in range(-5 * 100000, 5 * 100000 + 1):
	if i in c:
		ans = (ans + c[i]) % p
	if i - 1 in k:
		ans = (ans - k[i - 1]) % p
	count = (count + ans) % p
print(count % (10 ** 9 + 7))


n = int(input())
s = 0
for z in range(n):
	(b, d) = list(map(int, input().split()))
	if b >= 0 and d >= 0:
		s = s + (d - b + 1)
		s %= 10 ** 9 + 7
	elif b < 0 and d >= 0:
		s += d + abs(b) + 1
		s %= 10 ** 9 + 7
	else:
		s += abs(b) - abs(d) + 1
		s %= 10 ** 9 + 7
print(s % (1000000000 + 7))


from collections import *
t = 1
while t:
	t -= 1
	n = int(input())
	dis = [0 for i in range(1000001)]
	for i in range(n):
		(x, y) = list(map(int, input().split()))
		x += 500000
		y += 500000
		dis[x] += 1
		if y == 1000000:
			continue
		else:
			dis[y + 1] -= 1
	for i in range(1, len(dis)):
		dis[i] += dis[i - 1]
	print(sum(dis) % 1000000007)


M = int(1000000000.0 + 7)
I = lambda : list(map(int, input().split()))
n = I()[0]
(d, e) = ({}, {})
for i in range(-500000, 500001):
	(d[i], e[i]) = (0, 0)
for i in range(n):
	(a, b) = I()
	d[a] += 1
	e[b] += 1
(ans, cnt) = (0, 0)
for i in range(-500000, 500001):
	if d[i]:
		cnt += d[i]
	ans += cnt
	if ans >= M:
		ans -= M
	if ans < 0:
		ans += M
	if e[i]:
		cnt -= e[i]
print(ans)


from sys import stdin, stdout

def main():
	mod = 10 ** 9 + 7
	n = int(stdin.readline())
	neg = [0] * 500002
	pos = [0] * 500002
	counter = 0
	mn = 1000000
	mx = -1000000
	larr = []
	rarr = []
	for i in range(n):
		(l, r) = map(int, stdin.readline().split())
		if l < 0:
			counter = 1
			neg[abs(l)] += 1
		else:
			pos[l] += 1
		if r < 0:
			neg[abs(r) - 1] -= 1
		else:
			pos[abs(r) + 1] -= 1
	ans = 0
	for i in range(10 ** 5, 0, -1):
		neg[i] += neg[i + 1]
		ans = (ans + neg[i]) % mod
	neg[0] = neg[0] + neg[1]
	pos[0] = neg[0] + pos[0]
	ans = (ans + pos[0]) % mod
	for i in range(1, 10 ** 5 + 2):
		pos[i] = pos[i] + pos[i - 1]
		ans = (ans + pos[i]) % mod
	print(ans)
main()


N = int(input())
(L, L1, L2) = ([], {}, {})
for i in range(0, N):
	(x, y) = map(int, input().split())
	L.append(x)
	L.append(y)
	if x in L1:
		L1[x] += 1
	elif x not in L1:
		L1[x] = 1
	if y in L2:
		L2[y] += 1
	elif y not in L2:
		L2[y] = 1
L.sort()
persons = 0
s = 0
M = 1000000007
for elem in range(L[0], L[-1] + 1):
	if elem in L1:
		persons += L1[elem]
		deboard = False
	if elem in L2:
		deboard = True
	s += persons
	if deboard:
		persons -= L2[elem]
		deboard = False
print(s % M)


count = 0
for N in range(int(input())):
	(b, d) = map(int, input().split())
	if b >= 0:
		count += d - b + 1
	else:
		count += d + abs(b) + 1
print(count % (10 ** 9 + 7))


MOD = 10 ** 9 + 7
N = int(input())
mapsb = {}
mapsd = {}
start = float('inf')
end = -float('inf')
for i in range(N):
	(b, d) = list(map(int, input().split()))
	mapsb[b] = mapsb.get(b, 0) + 1
	mapsd[d] = mapsd.get(d, 0) + 1
	start = min(b, d, start)
	end = max(b, d, end)
severity = 0
infectionDegree = 0
for i in range(start, end + 1):
	if i in mapsb:
		infectionDegree += mapsb[i]
	severity += infectionDegree
	if i in mapsd:
		infectionDegree -= mapsd[i]
print(severity % MOD)


from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

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

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

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

def main():
	x = [0] * 1000005
	n = ii()
	c = 0
	for i in range(n):
		(x1, y1) = mi()
		x[x1 + 500001] += 1
		x[y1 + 500002] -= 1
		c = max(c, y1 + 500002)
	x[c] = 0
	s = 0
	for i in range(c):
		x[i] = (x[i] + x[i - 1]) % mod
		s = (s + x[i]) % mod
	print(s % mod)

def __starting_point():
	main()
__starting_point()


ss = 0
for _ in range(int(input())):
	s = list(map(int, input().split()))
	ss += len(list(range(s[0], s[1] + 1)))
print(ss % (10 ** 9 + 7))


count = 0
n = int(input())
for __ in range(n):
	(a, b) = map(int, input().split())
	count += b - a
print((count + n) % 1000000007)


M = 1000000007
n = int(input())
L = []
R = []
for i in range(n):
	(l, r) = list(map(int, input().split()))
	L.append(l)
	R.append(r)
LS = set(L)
RS = set(R)
LD = dict(list(zip(LS, [0] * len(LS))))
for e in L:
	LD[e] += 1
RD = dict(list(zip(RS, [0] * len(RS))))
for e in R:
	RD[e] += 1
L = dict(list(zip(L, [0] * n)))
R = dict(list(zip(R, [0] * n)))
inf = 0
total = 0
for i in range(min(LS), max(RS) + 1):
	if i in L:
		inf += LD[i]
	total += inf
	if i in R:
		inf -= RD[i]
print(total % M)


s = 0
n = int(input())
while n:
	mod = int(1000000000.0 + 7)
	(a, b) = [int(x) for x in input().split()]
	s += abs(b - a) + 1
	s %= mod
	n -= 1
print(s)


n = int(input())
modulus = 10 ** 9 + 7
s = 0
for i in range(n):
	l = list(map(int, input().split()))
	k = l[1] + 1 - l[0]
	if l[0] < 0 and l[1] < 0:
		k = l[0] - l[1] - 1
	s += abs(k)
print(s % modulus)


mod = 10 ** 9 + 7
summ = 0
N = int(input())
for _ in range(N):
	(a, b) = map(int, input().split())
	summ += b - a + 1
print(summ % mod)