Sam's house has an apple tree and an orange tree that yield an abundance of fruit. Using the information given below, determine the number of apples and oranges that land on Sam's house.  

In the diagram below: 

The red region denotes the house, where $\boldsymbol{\mathrm{~S~}}$ is the start point, and $\boldsymbol{\boldsymbol{t}}$ is the endpoint. The apple tree is to the left of the house, and the orange tree is to its right. 
Assume the trees are located on a single point, where the apple tree is at point $a$, and the orange tree is at point $\boldsymbol{b}$.
When a fruit falls from its tree, it lands $\boldsymbol{d}$ units of distance from its tree of origin along the $\boldsymbol{x}$-axis. *A negative value of $\boldsymbol{d}$ means the fruit fell $\boldsymbol{d}$ units to the tree's left, and a positive value of $\boldsymbol{d}$ means it falls $\boldsymbol{d}$ units to the tree's right. *

Given the value of $\boldsymbol{d}$ for $m$ apples and $n$ oranges, determine how many apples and oranges will fall on Sam's house (i.e., in the inclusive range $[s,t]$)?

For example, Sam's house is between $s=7$ and $t=10$.  The apple tree is located at $\boldsymbol{a}=4$ and the orange at $\boldsymbol{b=12}$.  There are $m=3$ apples and $n=3$ oranges.  Apples are thrown $apples=[2,3,-4]$ units distance from $\boldsymbol{\alpha}$, and $oranges=[3,-2,-4]$ units distance.  Adding each apple distance to the position of the tree, they land at $[4+2,4+3,4+-4]=[6,7,0]$.  Oranges land at $[12+3,12+-2,12+-4]=[15,10,8]$.  One apple and two oranges land in the inclusive range $7-10$ so we print 

1
2

Function Description  

Complete the countApplesAndOranges function in the editor below.  It should print the number of apples and oranges that land on Sam's house, each on a separate line.  

countApplesAndOranges has the following parameter(s):  

s: integer, starting point of Sam's house location.       
t: integer, ending location of Sam's house location.     
a: integer, location of the Apple tree.      
b: integer, location of the Orange tree.         
apples: integer array, distances at which each apple falls from the tree.      
oranges: integer array, distances at which each orange falls from the tree.  

Input Format

The first line contains two space-separated integers denoting the respective values of $\boldsymbol{\mathrm{~S~}}$ and $\boldsymbol{\boldsymbol{t}}$. 

The second line contains two space-separated integers denoting the respective values of $a$ and $\boldsymbol{b}$. 

The third line contains two space-separated integers denoting the respective values of $m$ and $n$. 

The fourth line contains $m$ space-separated integers denoting the respective distances that each apple falls from point $a$. 

The fifth line contains $n$ space-separated integers denoting the respective distances that each orange falls from point $\boldsymbol{b}$.

Constraints

$1\leq s,t,a,b,m,n\leq10^5$
$-10^5\leq d\leq10^5$
$a<s<t<b$

Output Format

Print two integers on two different lines:

The first integer:  the number of apples that fall on Sam's house.
The second integer:  the number of oranges that fall on Sam's house.  

Sample Input 0
7 11
5 15
3 2
-2 2 1
5 -6

Sample Output 0
1
1

Explanation 0

The first apple falls at position $5-2=3$. 

The second apple falls at position $5+2=7$. 

The third apple falls at position $5+1=6$. 

The first orange falls at position $15+5=20$. 

The second orange falls at position $15-6=9$. 

Only one fruit (the second apple) falls within the region between $7$ and $\mbox{11}$, so we print $1$ as our first line of output. 

Only the second orange falls within the region between $7$ and $\mbox{11}$, so we print $1$ as our second line of output.

Difficulty: EASY
Tags: Implementation

Starter code:

Solutions:
(s, t) = map(int, input().strip().split(' '))
(a, b) = map(int, input().strip().split(' '))
(m, n) = map(int, input().strip().split(' '))
apple = list(map(int, input().strip().split(' ')))
orange = list(map(int, input().strip().split(' ')))
sapple = sum([1 for f in apple if f + a >= s and f + a <= t])
sorange = sum([1 for f in orange if f + b >= s and f + b <= t])
print(sapple)
print(sorange)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
apples = sum([1 for ap in apple if a + ap >= s and a + ap <= t])
oranges = sum([1 for ora in orange if b + ora <= t and b + ora >= s])
print(apples)
print(oranges)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
c_app = 0
c_ora = 0
for x in range(len(apple)):
	d = apple[x] + a
	if s <= d <= t:
		c_app += 1
for x in range(len(orange)):
	d = orange[x] + b
	if s <= d <= t:
		c_ora += 1
print(c_app)
print(c_ora)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
count = 0
for i in range(len(apple)):
	if a + apple[i] >= s and a + apple[i] <= t:
		count += 1
print(count)
count = 0
for i in range(len(orange)):
	if b + orange[i] >= s and b + orange[i] <= t:
		count += 1
print(count)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
nb = 0
for ap in apple:
	if a + ap >= s and a + ap <= t:
		nb += 1
print(nb)
nb = 0
for org in orange:
	if b + org >= s and b + org <= t:
		nb += 1
print(nb)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) + a for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) + b for orange_temp in input().strip().split(' ')]
numApple = numOrange = 0
for i in apple:
	if s <= i <= t:
		numApple += 1
for i in orange:
	if s <= i <= t:
		numOrange += 1
print(numApple)
print(numOrange)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
countA = 0
countO = 0
for i in apple:
	if i + a >= s and i + a <= t:
		countA += 1
for j in orange:
	if j + b >= s and j + b <= t:
		countO += 1
print(countA)
print(countO)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
count1 = 0
for i in range(m):
	if a + apple[i] >= s and a + apple[i] <= t:
		count1 += 1
count2 = 0
for i in range(n):
	if b + orange[i] >= s and b + orange[i] <= t:
		count2 += 1
print(count1)
print(count2)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
app = 0
org = 0
for x in apple:
	if a + x >= s and a + x <= t:
		app += 1
for x in orange:
	if b + x >= s and b + x <= t:
		org += 1
print(app)
print(org)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
cnt = 0
c = 0
for i in apple:
	if s <= i + a <= t:
		cnt += 1
for j in orange:
	if s <= j + b <= t:
		c += 1
print(cnt)
print(c)


import sys
(houseStart, houseEnd) = input().strip().split(' ')
(houseStart, houseEnd) = [int(houseStart), int(houseEnd)]
(appleT, orangeT) = input().strip().split(' ')
(appleT, orangeT) = [int(appleT), int(orangeT)]
(apples, oranges) = input().strip().split(' ')
(apples, oranges) = [int(apples), int(oranges)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
totalA = 0
totalO = 0
for i in apple:
	if i + appleT >= houseStart and i + appleT <= houseEnd:
		totalA += 1
for i in orange:
	if i + orangeT >= houseStart and i + orangeT <= houseEnd:
		totalO += 1
print(totalA)
print(totalO)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
print(sum((1 if s <= a + da <= t else 0 for da in apple)))
print(sum((1 if s <= b + do <= t else 0 for do in orange)))


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
c = 0
for i in apple:
	if a + i >= s and a + i <= t:
		c = c + 1
d = 0
for i in orange:
	if b + i <= t and b + i >= s:
		d = d + 1
print(c)
print(d)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
apple_house = [a + d >= s and a + d <= t for d in apple]
print(sum(apple_house))
orange_house = [b + d >= s and b + d <= t for d in orange]
print(sum(orange_house))


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
apple = [i for i in apple if i > 0]
orange = [i for i in orange if i < 0]
(apple_count, orange_count) = (0, 0)
for i in apple:
	if s <= i + a <= t:
		apple_count += 1
for i in orange:
	if s <= i + b <= t:
		orange_count += 1
print(apple_count, end='\n')
print(orange_count)


def read_int_list():
	return [int(item) for item in input().strip().split(' ')]

def read_int_pair():
	line = input().strip().split(' ')
	return (int(line[0]), int(line[1]))

def in_house(p):
	return p >= house_left and p <= house_right

def fruits_in_house(tree, distances):
	res = 0
	for d in distances:
		if in_house(tree + d):
			res += 1
	return res
(house_left, house_right) = read_int_pair()
(apple_tree, orange_tree) = read_int_pair()
(num_apples, num_oranges) = read_int_pair()
apple_distances = read_int_list()
orange_distances = read_int_list()
print(fruits_in_house(apple_tree, apple_distances))
print(fruits_in_house(orange_tree, orange_distances))


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
cont = 0
for i in apple:
	if s <= i + a <= t:
		cont += 1
print(cont)
cont = 0
for i in orange:
	if s <= i + b <= t:
		cont += 1
print(cont)


(s, t) = map(int, input().split())
(a, b) = map(int, input().split())
(m, n) = map(int, input().split())
la = list(map(int, input().split()))
lo = list(map(int, input().split()))
apple = 0
orange = 0
for i in la:
	if a + i >= s and a + i <= t:
		apple += 1
for i in lo:
	if b + i <= t and b + i >= s:
		orange += 1
print(apple)
print(orange)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
c = 0
d = 0
for i in apple:
	if a + i >= s and a + i <= t:
		c = c + 1
for i in orange:
	if b + i >= s and b + i <= t:
		d = d + 1
print(c)
print(d)


(s, t) = [int(x) for x in input().split()]
(a, b) = [int(x) for x in input().split()]
(m, n) = [int(x) for x in input().split()]
ad = [int(x) + a for x in input().split()]
od = [int(x) + b for x in input().split()]
k = 0
for i in ad:
	if i >= s and i <= t:
		k += 1
print(k)
k = 0
for i in od:
	if i >= s and i <= t:
		k += 1
print(k)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
(apples, oranges) = (0, 0)
for i in apple:
	x = a + i
	if x >= s and x <= t:
		apples = apples + 1
for j in orange:
	y = b + j
	if y >= s and y <= t:
		oranges = oranges + 1
print(apples)
print(oranges)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
(apples, oranges) = (0, 0)
for x in apple:
	if x + a <= t and x + a >= s:
		apples += 1
for y in orange:
	if y + b <= t and y + b >= s:
		oranges += 1
print(apples)
print(oranges)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
app = len([x for x in apple if x + a >= s and x + a <= t])
ora = len([x for x in orange if x + b <= t and x + b >= s])
print(app)
print(ora)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
app_count = 0
orn_count = 0
for i in range(m):
	if s <= a + apple[i] <= t:
		app_count += 1
for i in range(n):
	if s <= b + orange[i] <= t:
		orn_count += 1
print(app_count)
print(orn_count)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
app = 0
ora = 0
for i in apple:
	if a + i >= s and a + i <= t:
		app += 1
for i in orange:
	if b + i >= s and b + i <= t:
		ora += 1
print(app)
print(ora)


(s, t) = map(int, input().strip().split())
(a, b) = map(int, input().strip().split())
(m, n) = map(int, input().strip().split())
apple = [d for d in input().strip().split() if s <= a + int(d) <= t]
orange = [d for d in input().strip().split() if s <= b + int(d) <= t]
print(len(apple))
print(len(orange))


(s, t) = map(int, input().split())
(a, b) = map(int, input().split())
input()
m = n = 0
for x in input().split():
	p = a + int(x)
	if p >= s and p <= t:
		m += 1
for x in input().split():
	p = b + int(x)
	if p >= s and p <= t:
		n += 1
print(m, n, sep='\n')


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
c = 0
d = 0
for x in range(m):
	if s <= a + apple[x] <= t:
		c = c + 1
for y in range(n):
	if s <= b + orange[y] <= t:
		d = d + 1
print(c)
print(d)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apples = [int(apple_temp) for apple_temp in input().strip().split(' ')]
oranges = [int(orange_temp) for orange_temp in input().strip().split(' ')]
apple_count = 0
for apple in apples:
	pos = a + apple
	if pos >= s and pos <= t:
		apple_count += 1
orange_count = 0
for orange in oranges:
	pos = b + orange
	if pos >= s and pos <= t:
		orange_count += 1
print(apple_count)
print(orange_count)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
num = 0
for i in apple:
	if a + i >= s and a + i <= t:
		num += 1
print(num)
num = 0
for i in orange:
	if b + i >= s and b + i <= t:
		num += 1
print(num)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) + a for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) + b for orange_temp in input().strip().split(' ')]
a_count = o_count = 0
for i in apple:
	if s <= i <= t:
		a_count += 1
for i in orange:
	if s <= i <= t:
		o_count += 1
print(a_count, o_count, sep='\n')


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
numapple = 0
numorange = 0
for ap in apple:
	if ap + a in range(s, t + 1):
		numapple += 1
for o in orange:
	if o + b in range(s, t + 1):
		numorange += 1
print(numapple)
print(numorange)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
count_app = 0
for app in apple:
	if a + app >= s and a + app <= t:
		count_app += 1
print(count_app)
count_orange = 0
for orr in orange:
	if b + orr >= s and b + orr <= t:
		count_orange += 1
print(count_orange)


import sys
(s, t) = map(int, input().split())
(a, b) = map(int, input().split())
at_len = t - a
as_len = s - a
ot_len = t - b
os_len = s - b
(m, n) = map(int, input().split())
a_n = 0
for ad in map(int, input().split()):
	if as_len <= ad <= at_len:
		a_n += 1
o_n = 0
for od in map(int, input().split()):
	if ot_len >= od >= os_len:
		o_n += 1
print(a_n, o_n, sep='\n')


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
num_a = 0
num_b = 0
for i in range(len(apple)):
	pos = a + apple[i]
	if pos >= s and pos <= t:
		num_a = num_a + 1
print(num_a)
for i in range(len(orange)):
	pos = b + orange[i]
	if pos >= s and pos <= t:
		num_b = num_b + 1
print(num_b)


import sys
(c1, c2) = (0, 0)
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
for i in apple:
	if s <= i + a <= t:
		c1 += 1
for i in orange:
	if s <= i + b <= t:
		c2 += 1
print(c1)
print(c2)


import sys
s = input().split()
low = int(s[0])
hig = int(s[1])
s = input().split()
a = int(s[0])
b = int(s[1])
s = input().split()
afruit = int(s[0])
bfruit = int(s[1])
apple = input().split()
jo = list(map(int, apple))
cou = int(0)
for j in range(0, len(jo)):
	if a + jo[j] >= low and a + jo[j] <= hig:
		cou += 1
print(cou)
cou = int(0)
apple = input().split()
jj = list(map(int, apple))
cou = int(0)
for j in range(0, len(jj)):
	if b + jj[j] >= low and b + jj[j] <= hig:
		cou += 1
print(cou)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
print(sum((s <= a + i <= t for i in apple)))
print(sum((s <= b + i <= t for i in orange)))


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
counter1 = 0
counter2 = 0
for i in apple:
	if i + a >= s and i + a <= t:
		counter1 += 1
for i in orange:
	if i + b <= t and i + b >= s:
		counter2 += 1
print(counter1, end='\n')
print(counter2)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
c1 = 0
c2 = 0
for i in range(m):
	c = a + apple[i]
	if c >= s and c <= t:
		c1 += 1
for i in range(n):
	c = b + orange[i]
	if c >= s and c <= t:
		c2 += 1
print(c1)
print(c2)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
apple_count = orange_count = 0
for i in apple:
	if s <= i + a <= t:
		apple_count += 1
print(apple_count)
for i in orange:
	if s <= i + b <= t:
		orange_count += 1
print(orange_count)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
ra = 0
for d in apple:
	if s <= a + d <= t:
		ra += 1
print(ra)
ro = 0
for d in orange:
	if s <= b + d <= t:
		ro += 1
print(ro)


(s, t) = map(int, input().split(' '))
(a, b) = map(int, input().split(' '))
input()
appled = map(int, input().split(' '))
oranged = map(int, input().split(' '))
i = 0
for x in appled:
	if a + x >= s and a + x <= t:
		i += 1
print(i)
i = 0
for x in oranged:
	if b + x >= s and b + x <= t:
		i += 1
print(i)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
_ = input()
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
(a_cnt, o_cnt) = (0, 0)
for i in apple:
	if a + i >= s and a + i <= t:
		a_cnt += 1
for i in orange:
	if b + i >= s and b + i <= t:
		o_cnt += 1
print(a_cnt)
print(o_cnt)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
house = range(s, t + 1)
cm = 0
cn = 0
for i in apple:
	if a + i in house:
		cm += 1
for j in orange:
	if b + j in house:
		cn += 1
print(cm)
print(cn)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
applecount = 0
orangecount = 0
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
for i in apple:
	if a + i >= s and a + i <= t:
		applecount += 1
for i in orange:
	if b + i >= s and b + i <= t:
		orangecount += 1
print(applecount)
print(orangecount)


import sys
(s, t) = map(int, input().strip().split(' '))
(a, b) = map(int, input().strip().split(' '))
(m, n) = map(int, input().strip().split(' '))
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
for i in range(len(apple) - 1, -1, -1):
	if not a + apple[i] in range(s, t + 1):
		del apple[i]
for i in range(len(orange) - 1, -1, -1):
	if not b + orange[i] in range(s, t + 1):
		del orange[i]
print(len(apple))
print(len(orange))


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
res = sum([1 for i in apple if a + i >= s and a + i <= t])
print(str(res))
res = sum([1 for i in orange if b + i >= s and b + i <= t])
print(str(res))


import sys
(s, t) = map(int, input().split())
(a, b) = map(int, input().split())
(m, n) = map(int, input().split())
print(sum((s <= pos + a <= t for pos in map(int, input().split()))))
print(sum((s <= pos + b <= t for pos in map(int, input().split()))))


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
ca = 0
co = 0
for i in apple:
	if i + a >= s and i + a <= t:
		ca += 1
for i in orange:
	if i + b <= t and i + b >= s:
		co += 1
print(ca)
print(co)


import sys
(s, t) = map(int, input().strip().split(' '))
(a, b) = map(int, input().strip().split(' '))
(m, n) = map(int, input().strip().split(' '))
apple = list(map(int, input().strip().split(' ')))
orange = list(map(int, input().strip().split(' ')))
app = 0
ora = 0
for x in apple:
	if x >= 0:
		if s <= a + x <= t:
			app += 1
for y in orange:
	if y <= 0:
		if s <= b - -1 * y <= t:
			ora += 1
print(app)
print(ora)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
app_total = 0
for ap in apple:
	app_position = a + ap
	if app_position >= s and app_position <= t:
		app_total += 1
ora_total = 0
for ora in orange:
	ora_position = b + ora
	if ora_position >= s and ora_position <= t:
		ora_total += 1
print(app_total)
print(ora_total)


(s, t) = map(int, input().split())
(a, b) = map(int, input().split())
(m, n) = map(int, input().split())
ad = map(int, input().split())
bd = map(int, input().split())
adl = s - a
adr = t - a
bdl = s - b
bdr = t - b
ret = 0
for d in ad:
	if adl <= d <= adr:
		ret += 1
print(ret)
ret = 0
for d in bd:
	if bdl <= d <= bdr:
		ret += 1
print(ret)


(s, t) = map(int, input().split())
(a, b) = map(int, input().split())
(m, n) = map(int, input().split())
apple_dist = list(map(int, input().split()))
orange_dist = list(map(int, input().split()))
count_apple = 0
count_oranges = 0
for i in range(m):
	if s <= apple_dist[i] + a <= t:
		count_apple += 1
for j in range(n):
	if s <= orange_dist[j] + b <= t:
		count_oranges += 1
print(count_apple)
print(count_oranges)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
aa = 0
for i in apple:
	if s <= a + i <= t:
		aa += 1
bb = 0
for i in orange:
	if s <= b + i <= t:
		bb += 1
print(aa)
print(bb)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
print(sum([s <= fruit + a <= t for fruit in apple]))
print(sum([s <= fruit + b <= t for fruit in orange]))


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
num_apple = len([x for x in apple if a + x >= s and a + x <= t])
print(num_apple)
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
num_orange = len([x for x in orange if b + x >= s and b + x <= t])
print(num_orange)


(s, t) = map(int, input().split())
(a, b) = map(int, input().split())
(m, n) = map(int, input().split())
nb_apples = 0
nb_oranges = 0
apples = list(map(int, input().split()))
for dist in apples:
	pos_apple = a + dist
	if pos_apple <= t and pos_apple >= s:
		nb_apples += 1
oranges = list(map(int, input().split()))
for dist in oranges:
	pos_orange = b + dist
	if pos_orange <= t and pos_orange >= s:
		nb_oranges += 1
print(nb_apples)
print(nb_oranges)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
c_ap = sum(map(lambda x: s <= x <= t, map(lambda x: x + a, apple)))
c_o = sum(map(lambda x: s <= x <= t, map(lambda x: x + b, orange)))
print(c_ap)
print(c_o)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
app_count = 0
or_count = 0
for item in apple:
	if a + item >= s and a + item <= t:
		app_count += 1
for item in orange:
	if b + item <= t and b + item >= s:
		or_count += 1
print(app_count)
print(or_count)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
mina = s - a
mino = t - b
maxa = t - a
maxo = s - b
(conta, conto) = (0, 0)
for k in apple:
	if k <= maxa and k >= mina:
		conta += 1
for j in orange:
	if j >= maxo and j <= mino:
		conto += 1
print(conta)
print(conto)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apples = [int(apple_temp) for apple_temp in input().strip().split(' ')]
oranges = [int(orange_temp) for orange_temp in input().strip().split(' ')]
ac = 0
for apple in apples:
	p = a + apple
	if p <= t and p >= s:
		ac += 1
print(ac)
oc = 0
for orange in oranges:
	p = b + orange
	if p <= t and p >= s:
		oc += 1
print(oc)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
x1 = s - a
x2 = t - a
x3 = s - b
x4 = t - b
count = 0
for x in apple:
	if x >= x1 and x <= x2:
		count += 1
print(count)
count = 0
for x in orange:
	if x >= x3 and x <= x4:
		count += 1
print(count)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
(count1, count2) = (0, 0)
for d in apple:
	if a + d >= s and a + d <= t:
		count1 += 1
for d in orange:
	if b + d >= s and b + d <= t:
		count2 += 1
print(count1)
print(count2)


(s, t) = [int(i) for i in input().strip().split(' ')]
(a, b) = [int(i) for i in input().strip().split(' ')]
(m, n) = [int(i) for i in input().strip().split(' ')]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
apple_list = [a + i for i in apple]
orange_list = [b + i for i in orange]
print(sum([1 for i in apple_list if s <= i <= t]))
print(sum([1 for i in orange_list if s <= i <= t]))


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
cnt_apple = 0
cnt_orange = 0
for i in range(m):
	if a + apple[i] in range(s, t + 1):
		cnt_apple += 1
for j in range(n):
	if b + orange[j] in range(s, t + 1):
		cnt_orange += 1
print(cnt_apple)
print(cnt_orange)


house_length = input().split()
house_length = list(map(int, house_length))
house_x = house_length[0]
house_y = house_length[1]
tree_pos = input().split()
tree_pos = list(map(int, tree_pos))
apple_tree = tree_pos[0]
orange_tree = tree_pos[1]
apple_orange_qty = input().split()
apple_orange_qty = list(map(int, apple_orange_qty))
m = apple_orange_qty[0]
n = apple_orange_qty[1]
distance_apple = input().split()
if len(distance_apple) == m:
	distance_apple = list(map(int, distance_apple))
distance_orange = input().split()
if len(distance_orange) == n:
	distance_orange = list(map(int, distance_orange))
temp_apple_dist = list()
temp_orange_dist = list()
for i in distance_apple:
	temp_apple_dist.append(i + apple_tree)
for i in distance_orange:
	temp_orange_dist.append(i + orange_tree)
apple = 0
orange = 0
for i in temp_apple_dist:
	if i >= house_x and i <= house_y:
		apple += 1
for i in temp_orange_dist:
	if i >= house_x and i <= house_y:
		orange += 1
print(apple)
print(orange)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
count1 = 0
count2 = 0
for x in apple:
	if x + a in range(s, t + 1):
		count1 += 1
print(count1)
for x in orange:
	if x + b in range(s, t + 1):
		count2 += 1
print(count2)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
appleCounter = 0
for i in range(m):
	applePosition = a + apple[i]
	if s <= applePosition and applePosition <= t:
		appleCounter += 1
orangeCounter = 0
for i in range(n):
	orangePosition = b + orange[i]
	if s <= orangePosition and orangePosition <= t:
		orangeCounter += 1
print(appleCounter)
print(orangeCounter)


(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
lst1 = [int(temp) for temp in input().strip().split(' ')]
lst2 = [int(temp) for temp in input().strip().split(' ')]
r_l = s - a
r_r = t - a
count1 = 0
for i in range(m):
	v = lst1[i]
	if v >= r_l and v <= r_r:
		count1 += 1
r_l = s - b
r_r = t - b
count2 = 0
for i in range(n):
	v = lst2[i]
	if v <= r_r and v >= r_l:
		count2 += 1
print(count1)
print(count2)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
res = 0
for d in apple:
	p = a + d
	if p >= s and p <= t:
		res += 1
print(res)
res = 0
for d in orange:
	p = b + d
	if p >= s and p <= t:
		res += 1
print(res)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
(noa, noo) = (0, 0)
for i in apple:
	temp = a + i
	if temp >= s and temp <= t:
		noa += 1
for i in orange:
	temp = b + i
	if temp >= s and temp <= t:
		noo += 1
print(noa)
print(noo)


(s, t) = map(int, input().split())
(a, b) = map(int, input().split())
(num_a, num_o) = map(int, input().split())
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
(apple_dist_s, apple_dist_t) = (s - a, t - a)
(orange_dist_s, orange_dist_t) = (s - b, t - b)
(c1, c2) = (0, 0)
for i in apple:
	if i >= apple_dist_s and i <= apple_dist_t:
		c1 += 1
for j in orange:
	if j >= orange_dist_s and j <= orange_dist_t:
		c2 += 1
print(c1)
print(c2)


(s, t) = map(int, input().split())
(a, b) = map(int, input().split())
(num_a, num_o) = map(int, input().split())
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
(apple_dist_s, apple_dist_t) = (s - a, t - a)
(orange_dist_s, orange_dist_t) = (s - b, t - b)
(c1, c2) = (0, 0)
for i in apple:
	if i >= apple_dist_s and i <= apple_dist_t:
		c1 += 1
for j in orange:
	if j >= orange_dist_s and j <= orange_dist_t:
		c2 += 1
print(c1)
print(c2)


(s, t) = tuple(map(int, input().split()))
(a, b) = tuple(map(int, input().split()))
(m, n) = tuple(map(int, input().split()))
print(sum((1 for apple in map(int, input().split()) if s <= a + apple <= t)))
print(sum((1 for orange in map(int, input().split()) if s <= b + orange <= t)))


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apples = [int(apple_temp) for apple_temp in input().strip().split(' ')]
oranges = [int(orange_temp) for orange_temp in input().strip().split(' ')]
apples_sam = 0
for apple in apples:
	landing_point = a + apple
	if landing_point >= s and landing_point <= t:
		apples_sam += 1
print(apples_sam)
oranges_sam = 0
for orange in oranges:
	landing_point = b + orange
	if landing_point >= s and landing_point <= t:
		oranges_sam += 1
print(oranges_sam)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
li1 = []
li2 = []
for i in apple:
	if a + i >= s and a + i <= t:
		li1.append(a + i)
for i in orange:
	if b + i >= s and b + i <= t:
		li2.append(b + i)
print(len(li1))
print(len(li2))


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
b -= a
s -= a
t -= a
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = list(filter(lambda x: int(x) >= s and int(x) <= t, input().strip().split(' ')))
orange = list(filter(lambda x: int(x) + b <= t and int(x) + b >= s, input().strip().split(' ')))
print(len(apple))
print(len(orange))


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
a_dist_list = [a + appd for appd in apple]
o_dist_list = [b + od for od in orange]
a_count = 0
o_count = 0
for apple_temp in a_dist_list:
	if s <= apple_temp <= t:
		a_count += 1
for orange_temp in o_dist_list:
	if s <= orange_temp <= t:
		o_count += 1
print(a_count)
print(o_count)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
acount = 0
ocount = 0
for k in apple:
	dist = a + k
	if dist >= s and dist <= t:
		acount = acount + 1
for j in orange:
	dist2 = b + j
	if dist2 >= s and dist2 <= t:
		ocount = ocount + 1
print(acount)
print(ocount)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
num_oranges = sum([True if s <= b + o <= t else False for o in orange])
num_apples = sum([True if s <= a + ap <= t else False for ap in apple])
print(num_apples)
print(num_oranges)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]

def test_apple(x):
	return a + x >= s and a + x <= t

def test_orange(x):
	return b + x >= s and b + x <= t
print(sum([test_apple(a) for a in apple]))
print(sum([test_orange(o) for o in orange]))


(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
countApple = countOrange = 0
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
for i in apple:
	if a + i >= s and a + i <= t:
		countApple += 1
print(countApple)
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
for i in orange:
	if b + i >= s and b + i <= t:
		countOrange += 1
print(countOrange)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
x1 = s - a
x2 = t - a
y1 = t - b
y2 = s - b
k = t - s
ap = 0
orn = 0
for i in range(0, m):
	if apple[i] <= x2 and apple[i] >= x1 and (apple[i] > 0):
		ap += 1
for i in range(0, n):
	if orange[i] >= y2 and orange[i] <= y1 and (orange[i] < 0):
		orn += 1
print(ap)
print(orn)


import sys

def num_apples(s, t, a, m, apple):
	num_apples_fell = 0
	for distance in apple:
		if distance >= s - a and distance <= t - a:
			num_apples_fell = num_apples_fell + 1
	return num_apples_fell

def num_oranges(s, t, b, n, orange):
	num_oranges_fell = 0
	for distance in orange:
		if distance >= s - b and distance <= t - b:
			num_oranges_fell = num_oranges_fell + 1
	return num_oranges_fell
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
print(num_apples(s, t, a, m, apple))
print(num_oranges(s, t, b, n, orange))


(s, t) = map(int, input().split())
(a, b) = map(int, input().split())
(m, n) = map(int, input().split())
apples = list(map(int, input().split()))
oranges = list(map(int, input().split()))
apples = [apple for apple in apples if s <= apple + a <= t]
oranges = [orange for orange in oranges if s <= orange + b <= t]
print(len(apples))
print(len(oranges))


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
ap = 0
ora = 0
for i in apple:
	if a + i >= s and a + i <= t:
		ap += 1
	else:
		continue
for j in orange:
	if b + j >= s and b + j <= t:
		ora += 1
	else:
		continue
print(ap)
print(ora)


import sys

def onHouse(s, t, fruitLandings):
	sum = 0
	for i in fruitLandings:
		if i >= s and i <= t:
			sum += 1
	return sum
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
appleLanding = [a + x for x in apple]
orangeLanding = [b + x for x in orange]
print(onHouse(s, t, appleLanding))
print(onHouse(s, t, orangeLanding))


(s, t) = map(int, input().strip().split(' '))
(a, b) = map(int, input().strip().split(' '))
(m, n) = map(int, input().strip().split(' '))
apple = list(map(int, input().split()))
orange = list(map(int, input().split()))
ap = 0
orn = 0
for i in range(len(apple)):
	if t >= a + apple[i] >= s:
		ap += 1
for i in range(len(orange)):
	if t >= b + orange[i] >= s:
		orn += 1
print(ap)
print(orn)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
apple_count = 0
orange_count = 0
for i in apple:
	if a + i >= s and a + i <= t:
		apple_count = apple_count + 1
for i in orange:
	if b + i >= s and b + i <= t:
		orange_count = orange_count + 1
print(apple_count)
print(orange_count)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
apl = 0
for i in range(m):
	if apple[i] >= s - a and apple[i] <= t - a:
		apl = apl + 1
org = 0
for i in range(n):
	if -1 * orange[i] >= b - t and -1 * orange[i] <= b - s:
		org = org + 1
print(apl)
print(org)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
apples = 0
oranges = 0
for item in apple:
	if item >= s - a and item <= t - a:
		apples += 1
for item in orange:
	if item >= s - b and item <= t - b:
		oranges += 1
print(apples)
print(oranges)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
count_a = 0
count_b = 0
for d in apple:
	if a + d >= s and a + d <= t:
		count_a += 1
for d in orange:
	if b + d >= s and b + d <= t:
		count_b += 1
print(count_a)
print(count_b)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
appCount = 0
for i in apple:
	if a + i >= s and a + i <= t:
		appCount += 1
print(appCount)
orCount = 0
for i in orange:
	if b + i >= s and b + i <= t:
		orCount += 1
print(orCount)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
apples = [x + a for x in apple]
oranges = [x + b for x in orange]
a = 0
o = 0
for i in apples:
	if i in range(s, t + 1):
		a += 1
for i in oranges:
	if i in range(s, t + 1):
		o += 1
print(a)
print(o)


(s, t) = input().split()
(a, b) = input().split()
(m, n) = input().split()
M = input().split()
N = input().split()
res = 0
for i in range(int(m)):
	if int(M[i]) + int(a) >= int(s) and int(M[i]) + int(a) <= int(t):
		res += 1
print(res)
res1 = 0
for i in range(int(n)):
	if int(N[i]) + int(b) >= int(s) and int(N[i]) + int(b) <= int(t):
		res1 += 1
print(res1)


def main():
	(s, t) = map(int, input().split())
	(a, b) = map(int, input().split())
	input()
	print(sum((s <= a + int(x) <= t for x in input().split())))
	print(sum((s <= b + int(x) <= t for x in input().split())))
main()


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
print(sum([s <= a + x <= t for x in apple]))
print(sum([s <= b + x <= t for x in orange]))


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]
ctr = 0
ctr1 = 0
for i in apple:
	if a + i >= s and a + i <= t:
		ctr = ctr + 1
for i in orange:
	if b + i >= s and b + i <= t:
		ctr1 = ctr1 + 1
print(ctr)
print(ctr1)


import sys
(s, t) = input().strip().split(' ')
(s, t) = [int(s), int(t)]
(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
(m, n) = input().strip().split(' ')
(m, n) = [int(m), int(n)]
apple = [int(apple_temp) for apple_temp in input().strip().split(' ')]
orange = [int(orange_temp) for orange_temp in input().strip().split(' ')]

def isOnHouse(s, t, treePos, fruits):
	fruitsFall = [treePos + f for f in fruits if treePos + f >= s and treePos + f <= t]
	print(len(fruitsFall))
isOnHouse(s, t, a, apple)
isOnHouse(s, t, b, orange)