Petya and Vasya are tossing a coin. Their friend Valera is appointed as a judge. The game is very simple. First Vasya tosses a coin x times, then Petya tosses a coin y times. If the tossing player gets head, he scores one point. If he gets tail, nobody gets any points. The winner is the player with most points by the end of the game. If boys have the same number of points, the game finishes with a draw.

At some point, Valera lost his count, and so he can not say exactly what the score is at the end of the game. But there are things he remembers for sure. He remembers that the entire game Vasya got heads at least a times, and Petya got heads at least b times. Moreover, he knows that the winner of the game was Vasya. Valera wants to use this information to know every possible outcome of the game, which do not contradict his memories.


-----Input-----

The single line contains four integers x, y, a, b (1 ≤ a ≤ x ≤ 100, 1 ≤ b ≤ y ≤ 100). The numbers on the line are separated by a space.


-----Output-----

In the first line print integer n — the number of possible outcomes of the game. Then on n lines print the outcomes. On the i-th line print a space-separated pair of integers c_{i}, d_{i} — the number of heads Vasya and Petya got in the i-th outcome of the game, correspondingly. Print pairs of integers (c_{i}, d_{i}) in the strictly increasing order.

Let us remind you that the pair of numbers (p_1, q_1) is less than the pair of numbers (p_2, q_2), if p_1 < p_2, or p_1 = p_2 and also q_1 < q_2.


-----Examples-----
Input
3 2 1 1

Output
3
2 1
3 1
3 2

Input
2 4 2 2

Output
0

Difficulty: EASY
Tags: Implementation

Complete search
Skill types: Complete search

Starter code:

Solutions:
def main():
	(x, y, a, b) = [int(i) for i in input().split()]
	l = []
	count = 0
	for i in range(a, x + 1):
		for j in range(b, y + 1):
			if i > j:
				count += 1
				l.append([i, j])
	print(len(l))
	for i in l:
		print(*i)
	return 0
main()


(x, y, a, b) = map(int, input().split())
result = []
for i in range(a, x + 1):
	for j in range(b, min(i, y + 1)):
		result.append((i, j))
print(len(result))
for (x, y) in result:
	print(x, y)


(x, y, a, b) = map(int, input().split(' '))
count = 0
flag = 1
comb = []
if a < b:
	if x >= b:
		a = b
	else:
		print(0)
		flag = 0
if flag is not 0:
	for i in range(a, x + 1):
		for j in range(b, min(i + 1, y + 1)):
			if i is j:
				continue
			else:
				comb.append([i, j])
				count += 1
	print(count)
	if count > 0:
		for i in comb:
			print(*i)


(x, y, a, b) = map(int, input().split())
ans = []
for vasya in range(max(b + 1, a), x + 1):
	for petya in range(b, min(vasya, y + 1)):
		ans.append((petya, vasya))
print(len(ans))
print('\n'.join(['%d %d' % (b, a) for (a, b) in ans]))


(a, b, c, d) = list(map(int, input().split(' ')))
ct = 0
ct2 = 0
badtoed = []
for i in range(1, a + 1):
	for j in range(1, b + 1):
		if i > j and i >= c and (j >= d):
			badtoed.append(str(i) + ' ' + str(j))
			ct += 1
print(ct)
for i in badtoed:
	print(i)


s = [int(i) for i in input().split()]
x = s[3]
y = 0
if s[2] > s[3]:
	y = s[2]
else:
	y = x + 1
d = []
while y <= s[0]:
	x = s[3]
	while x <= s[1]:
		if y > x:
			d.append(str(y) + ' ' + str(x))
		x += 1
	y += 1
print(len(d))
for i in range(len(d)):
	print(d[i])


import os
import sys
import math
from io import BytesIO, IOBase
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

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

def dijkstra(start, distance, path, n):
	visited = [False for _ in range(n)]
	distance[start] = 0
	for i in range(n):
		v = -1
		for j in range(n):
			if not visited[v] and (v == -1 or distance[j] < distance[v]):
				v = j
		if distance[v] == math.inf:
			break
		visited[v] = True
		for edge in adj[v]:
			destination = edge[0]
			weight = edge[1]
			if distance[v] + weight < distance[destination]:
				distance[destination] = distance[v] + weight
				path[destination] = v

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

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

def ncr(n, r):
	return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def npr(n, r):
	return math.factorial(n) // math.factorial(n - r)

def seive(n):
	primes = [True] * (n + 1)
	ans = []
	for i in range(2, n):
		if not primes[i]:
			continue
		j = 2 * i
		while j <= n:
			primes[j] = False
			j += i
	for p in range(2, n + 1):
		if primes[p]:
			ans += [p]
	return ans

def factors(n):
	factors = []
	x = 1
	while x * x <= n:
		if n % x == 0:
			if n // x == x:
				factors.append(x)
			else:
				factors.append(x)
				factors.append(n // x)
		x += 1
	return factors

def main():
	try:
		import heapq
		(x, y, a, b) = invr()
		arr = [i for i in range(a, x + 1)]
		brr = [i for i in range(b, y + 1)]
		(ans, ans_arr) = (0, [])
		for i in arr:
			for j in brr:
				if i > j:
					heapq.heappush(ans_arr, [i, j])
					ans += 1
		print(ans)
		for i in ans_arr:
			print(*i, sep=' ')
	except Exception as e:
		print(e)
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()


z = input()
L = z.split()
x = int(L[0])
y = int(L[1])
a = int(L[2])
b = int(L[3])
L1 = []
p = 0
if x <= b:
	print('0')
else:
	for i in range(a, x + 1):
		for k in range(b, y + 1):
			if i > k:
				L1 = L1 + [i]
				L1 = L1 + [k]
if x > b:
	print(int(len(L1) / 2))
	while 2 * p < len(L1):
		print(int(L1[2 * p]), int(L1[2 * p + 1]))
		p = p + 1


(x, y, a, b) = map(int, input().split())
c = 0
xx = []
for i in range(a, x + 1):
	for j in range(b, y + 1):
		if i > j:
			c += 1
			xx.append([i, j])
print(c)
for i in range(c):
	print(xx[i][0], xx[i][1])


(x, y, a, b) = map(int, input().split())
ht = []
for i in range(a, x + 1):
	for j in range(b, y + 1):
		if i > j:
			ht.append((i, j))
print(len(ht))
for i in range(len(ht)):
	print(*ht[i])


(x, y, a, b) = [int(x) for x in input().split(' ')]
r = []
for i in range(a, x + 1):
	for j in range(b, y + 1):
		if i > j:
			r.append([i, j])
l = len(r)
r.sort(key=lambda z: 10 * l * z[0] + z[1])
print(len(r))
list(map(lambda z: print('%s %s' % (z[0], z[1])), r))


(x, y, a, b) = map(int, input().split())
if a < b and x - a <= b - a or (a == b and x < y):
	print(0)
else:
	c = 0
	for i in range(a, x + 1):
		for j in range(b, y + 1):
			if i > j:
				c = c + 1
	print(c)
	for i in range(a, x + 1):
		for j in range(b, y + 1):
			if i > j:
				print(i, j)


def main():
	(x, y, a, b) = [int(c) for c in input().split()]
	aset = list(range(a, x + 1))
	bset = list(range(b, y + 1))
	res = []
	for aa in aset:
		for bb in bset:
			if aa > bb:
				res.append((aa, bb))
	print(len(res))
	for e in res:
		print(*e)
main()


def main():
	(x, y, a, b) = map(int, input().split())
	res = [None]
	for i in range(a, x + 1):
		si = str(i)
		for j in range(b, min(y + 1, i)):
			res.append(' '.join((si, str(j))))
	res[0] = str(len(res) - 1)
	print('\n'.join(res))

def __starting_point():
	main()
__starting_point()


(x, y, a, b) = input().split()
x = int(x)
y = int(y)
a = int(a)
b = int(b)
l = []
for i in range(b, y + 1):
	for j in range(max(a, i + 1), x + 1):
		l.append((j, i))
print(len(l))
l.sort(key=lambda x: x[0])
for i in range(len(l)):
	print(l[i][0], l[i][1])


alll = []
(x, y, a, b) = [int(x) for x in input().split()]
for i in range(a, x + 1):
	for j in range(b, y + 1):
		if i > j:
			alll.append((i, j))
print(len(alll))
print('\n'.join([' '.join([str(x) for x in v]) for v in alll]))


def solve():
	(x, y, a, b) = map(int, input().split())
	newA = a
	res = []
	while newA <= x:
		newB = b
		while newB <= y and newB < newA:
			res.append((newA, newB))
			newB += 1
		newA += 1
	n = len(res)
	print(n)
	for (x, y) in res:
		print(x, y)
	return
solve()


arr = input().split()
p = int(arr[0])
q = int(arr[1])
a = int(arr[2])
b = int(arr[3])
flag = 0
if a <= b:
	a = b + 1
x = b
y = a
while a <= p:
	b = x
	while b < a and b <= q:
		flag += 1
		b += 1
	a += 1
print(str(flag))
a = y
b = x
while a <= p:
	b = x
	while b < a and b <= q:
		flag += 1
		print(str(a) + ' ' + str(b))
		b += 1
	a += 1


def g(n):
	k = n - a + 1
	return (n + a) * k // 2 - b * k
(x, y, a, b) = list(map(int, input().split()))
a = max(a, b + 1)
if x <= b:
	print(0)
elif y > x - 2:
	print(g(x))
elif y >= a - 1:
	print((x - y - 1) * (y - b + 1) + g(y + 1))
else:
	print((x - a + 1) * (y - b + 1))
for i in range(a, x + 1):
	for j in range(b, min(i, y + 1)):
		print(i, j)


def all_outcome(x, y, a, b):
	s = x + y
	outcomes = []
	for c in range(a, x + 1):
		for d in range(b, y + 1):
			if d >= b and d <= y and (c > d):
				outcomes.append([c, d])
	print(len(outcomes))
	for o in outcomes:
		print(o[0], o[1])
l = input().split()
x = int(l[0])
y = int(l[1])
a = int(l[2])
b = int(l[3])
all_outcome(x, y, a, b)


import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def cdiv(n, k):
	return n // k + (n % k != 0)

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

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

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

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

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def rev(n):
	m = 0
	while n > 0:
		m = m * 10 + n % 10
		n = n // 10
	return m
(x, y, a, b) = mi()
ans = []
for i in range(max(a, b), x + 1):
	for j in range(b, min(y + 1, i)):
		ans.append([i, j])
print(len(ans))
for i in range(len(ans)):
	print(' '.join(map(str, ans[i])))


(x, y, a, b) = map(int, input().split())
Results = []
for i in range(a, x + 1):
	for j in range(b, y + 1):
		if j >= i:
			continue
		Results.append((i, j))
print(len(Results))
Results.sort()
for item in Results:
	print(item[0], item[1])


(x, y, a, b) = map(int, input().split())
n = 0
outcomes = []
for i in range(max(a, b + 1), x + 1):
	for j in range(b, min(i, y + 1)):
		n += 1
		outcomes.append((i, j))
print(n)
for (a, b) in outcomes:
	print(a, b)


(x, y, a, b) = map(int, input().split())
i = a
l = []
while i <= x:
	j = b
	if i <= j:
		i += 1
	else:
		while j < i and j <= y:
			z = [i, j]
			l.append(z)
			j += 1
		i += 1
print(len(l))
for x in l:
	print(x[0], x[1])


class CodeforcesTask242ASolution:

	def __init__(self):
		self.result = ''
		self.x_y_a_b = []

	def read_input(self):
		self.x_y_a_b = [int(x) for x in input().split(' ')]

	def process_task(self):
		games = []
		for x in range(self.x_y_a_b[2], self.x_y_a_b[0] + 1):
			for y in range(self.x_y_a_b[3], x):
				if y <= self.x_y_a_b[1]:
					games.append('{0} {1}\n'.format(x, y))
		self.result = '{0}\n{1}'.format(len(games), ''.join(games))

	def get_result(self):
		return self.result
Solution = CodeforcesTask242ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


(x, y, a, b) = map(int, input('').split(' '))
ans = 0
for i in range(a, x + 1):
	for j in range(b, y + 1):
		if i > j:
			ans = ans + 1
print(ans)
for i in range(a, x + 1):
	for j in range(b, y + 1):
		if i > j:
			print(f'{i} {j}')


(x, y, a, b) = map(int, input().split())
l = []
if x <= b:
	print(0)
else:
	t = max(b + 1, a)
	i = a
	while i <= x:
		for j in range(b, min(i, y + 1)):
			l.append((i, j))
		i = i + 1
	print(len(l))
	for i in l:
		print(i[0], i[1])


(x, y, a, b) = map(int, input().split())
C = [(i, j) for i in range(max(a, b + 1), x + 1) for j in range(b, min(i, y + 1))]
print(len(C))
for c in C:
	print(*c)


iarr = list(map(int, input().split()))
x = iarr[0]
y = iarr[1]
a = iarr[2]
b = iarr[3]
ans = []
for i in range(a, x + 1):
	for j in range(b, y + 1):
		if i > j:
			ans.append((i, j))
print(len(ans))
for i in ans:
	print(i[0], i[1])


f = input().split()
a = int(f[0])
b = int(f[1])
am = int(f[2])
bm = int(f[3])
l = []
for i in range(bm + 1, a + 1):
	if i > bm and i >= am:
		for j in range(bm, i):
			if j <= b:
				p = []
				p.append(i)
				p.append(j)
				l.append(p)
if len(l) == 0:
	print(0)
else:
	print(len(l))
	for i in range(len(l)):
		print(l[i][0], l[i][1])


(x, y, a, b) = [int(i) for i in input().split()]
left = x - a
if left + a <= b:
	print(0)
	exit()
ans = []
for i in range(max(a, b + 1), x + 1):
	for j in range(b, min(i, y + 1)):
		ans.append([i, j])
print(len(ans))
for i in ans:
	print(i[0], i[1])


(x, y, a, b) = map(int, input().split())
ans = []
for i in range(a, x + 1):
	for j in range(b, y + 1):
		if i > j:
			ans.append((i, j))
ans.sort()
print(len(ans))
for x in ans:
	print(x[0], x[1])


import sys
import string
from collections import Counter, defaultdict
from math import fsum, sqrt, gcd, ceil, factorial
from itertools import combinations, permutations
flush = lambda : sys.stdout.flush
comb = lambda x, y: factorial(x) // factorial(y) // factorial(x - y)
ip = lambda : input()
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())
(a, b, x, y) = r()
arr = []
for i in range(x, a + 1):
	for j in range(y, min(b + 1, i)):
		arr.append([i, j])
print(len(arr))
for i in arr:
	print(*i)


(x, y, a, b) = map(int, input().split())
(vas, pet) = (a, b)
ans = []
while vas <= x:
	pet = b
	while pet < vas and pet <= y:
		ans.append([vas, pet])
		pet += 1
	vas += 1
print(len(ans))
for i in range(len(ans)):
	print(*ans[i])


(x, y, a, b) = [int(i) for i in input().split()]
arr = []
for i in range(x - a + 1):
	a_wins = a + i
	if a_wins > b:
		for j in range(a_wins):
			b_wins = b + j
			if b_wins <= y and a_wins > b_wins:
				arr += [[a_wins, b_wins]]
print(len(arr))
for vals in arr:
	print(' '.join([str(i) for i in vals]))


(x, y, a, b) = map(int, input().split())
c = []
for aa in range(a, x + 1):
	for bb in range(b, y + 1):
		if aa > bb:
			c.append([aa, bb])
print(len(c))
for x in c:
	print(x[0], x[1])


(x, y, a, b) = map(int, input().split())
a = max(a, b + 1)
ans = []
while a <= x:
	z = b
	while z < a and z <= y:
		ans.append('%i %i' % (a, z))
		z += 1
	a += 1
print(len(ans))
if len(ans) > 0:
	print('\n'.join(ans))


(x, y, a, b) = map(int, input().split())
p = max(a, b + 1)
A = []
for i in range(p, x + 1):
	for j in range(b, min(i, y + 1)):
		A.append([i, j])
print(len(A))
for (i, j) in A:
	print(i, j)


(x, y, a, b) = map(int, input().split())
results = []
for i in range(a, x + 1):
	for j in range(b, y + 1):
		if i <= j:
			continue
		results.append((i, j))
print(len(results))
results.sort()
for (a, b) in results:
	print(a, b)


def read_int():
	return int(input())

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

def print_nums(nums):
	print(' '.join(map(str, nums)))
(x, y, a, b) = read_ints()
res = []
for A in range(max(a, b + 1), x + 1):
	for B in range(b, min(A - 1, y) + 1):
		res.append((A, B))
print(len(res))
for (A, B) in res:
	print('%d %d' % (A, B))


def headTails(x, y, a, b):
	p_a = list(range(a, x + 1))
	p_b = list(range(b, min(x + 1, y + 1)))
	arr = []
	i = 0
	j = 0
	while i < len(p_a) and j < len(p_b):
		if p_a[i] > p_b[j]:
			arr.append((p_a[i], p_b[j]))
			if i < len(p_a):
				for k in range(i + 1, len(p_a)):
					arr.append((p_a[k], p_b[j]))
			j += 1
		else:
			i += 1
	arr.sort(key=lambda x: x[0])
	print(len(arr))
	for i in arr:
		print(*i)
(x, y, a, b) = list(map(int, input().split()))
headTails(x, y, a, b)


(x, y, a, b) = [int(x) for x in input().split()]
rs = []
for i in range(b, y + 1, 1):
	for j in range(a, x + 1, 1):
		if j > i:
			rs.append([j, i])
print(len(rs))
rs = sorted(rs, key=lambda x: x[0])
for (a, b) in rs:
	print(a, b)


(x, y, a, b) = list(map(int, input().split()))
if b == y and x <= y:
	print('0')
else:
	if a == b:
		initial = a + 1
	elif b > a:
		initial = b + 1
	else:
		initial = a
	arr = []
	for i in range(initial, x + 1):
		for j in range(b, min(y + 1, i)):
			arr.append([i, j])
	arr.sort()
	print(len(arr))
	for i in range(len(arr)):
		print('%d %d' % (arr[i][0], arr[i][1]))


(x, y, a, b) = list(map(int, input().split(' ')))
ans = 0
result = ''
for i in range(a, x + 1):
	for j in range(b, y + 1):
		if i > j:
			ans += 1
			result += '%s %s\n' % (i, j)
print(ans)
if ans:
	print(result)


l = input().split()
l = [int(x) for x in l]
x = l[0]
y = l[1]
a = l[2]
b = l[3]
r = []
for i in range(a, x + 1):
	for j in range(b, y + 1):
		if i > j:
			r.append((i, j))
		else:
			break
print(len(r))
for x in r:
	print(x[0], x[1])


(a, b, c, d) = map(int, input().split())
x = max(d + 1, c)
ans = []
for i in range(x, a + 1):
	for j in range(d, min(i, b + 1)):
		ans.append(str(i) + ' ' + str(j))
print(len(ans))
print('\n'.join(ans))


a = input()
a = a.split(' ')
a = [*map(int, a)]
b = a[1]
c = a[2]
d = a[3]
a = a[0]
e = c
f = d
g = []
h = []
while e <= a:
	f = e
	for o in range(d, f + 1):
		if o < e and o <= b:
			h.append(o)
			g.append(e)
	e += 1
print(len(g))
for i in range(len(g)):
	print(g[i], h[i])


(x, y, a, b) = map(int, input().split())
final = []
start = a if a > b else b + 1
for i in range(start, x + 1):
	for j in range(b, y + 1):
		if i > j:
			final.append([i, j])
		else:
			break
print(len(final))
for i in range(len(final)):
	print(*final[i])


(x, y, a, b) = map(int, input('').split())
t = [a, b]
c = 0
k = []
count = 0
p = 0
while c == 0:
	if t[0] > x:
		break
	if t[0] <= x:
		if t[1] > y:
			break
		if t[1] <= y:
			if t[0] > t[1]:
				count += 1
				k.append([])
				k[p].append(t[0])
				k[p].append(t[1])
				p += 1
			if t[1] + 1 > y:
				t[0] += 1
				t[1] = b
			else:
				t[1] += 1
print(count)
for l in range(len(k)):
	print(k[l][0], k[l][1])


(x, y, a, b) = list(map(int, input().split()))
a = max(a, b + 1)
c = []
s = 0
for i in range(a, x + 1):
	for j in range(b, min(i, y + 1)):
		c.append((i, j))
		s += 1
if s == 0:
	print(s)
else:
	print(s)
	for (i, j) in c:
		print(i, j)


(x, y, a, b) = map(int, input().split())
ans = []
for i in range(max(a, b + 1), x + 1):
	for j in range(b, min(i, y + 1)):
		ans.append('{} {}'.format(i, j))
print(len(ans))
if len(ans) > 0:
	print('\n'.join(ans))


entrada = list([int(x) for x in input().split()])
qtdjogadasVencedor = entrada[0]
qtdjogadasPerdedor = entrada[1]
qtdminpontVencedor = entrada[2]
qtdminpontPerdedor = entrada[3]
(listaPrincipal, laux) = ([], [])
for i in range(qtdminpontVencedor, qtdjogadasVencedor + 1):
	for j in range(qtdminpontPerdedor, qtdjogadasPerdedor + 1):
		if j < i:
			laux.append((i, j))
print(len(laux))
for i in laux:
	print(i[0], i[1])


(x, y, a, b) = map(int, input().split())
ans = 0
l1 = []
if x > b:
	if a <= b:
		a = b + 1
	while a <= x:
		f = b
		while a > f and f <= y:
			l1.append((a, f))
			ans += 1
			f += 1
		a += 1
print(ans)
for item in l1:
	print(item[0], item[1])


import sys
f = sys.stdin
(x, y, a, b) = map(int, f.readline().strip().split())
(a1, a2) = ([], [])
if a + (x - a) <= b:
	print(0)
else:
	for i in range(a, x + 1):
		for k in range(b, y + 1):
			if i > k:
				a1.append(i)
				a2.append(k)
	print(len(a1))
	for i in range(len(a1)):
		print(a1[i], a2[i])


data = input().split(' ')
x = int(data[0])
y = int(data[1])
a = int(data[2])
b = int(data[3])
counter = 0
for i in range(a, x + 1):
	for j in range(b, y + 1):
		if j < i:
			counter += 1
if counter == 0:
	print(0)
else:
	print(counter)
	for i in range(a, x + 1):
		for j in range(b, y + 1):
			if j < i:
				print('%s %s' % (i, j))
				noAnswer = False


(max_vasya, max_petya, min_vasya, min_petya) = map(int, input().split())
num_solutions = 0
solutions = list()
for vasya in range(min_vasya, max_vasya + 1):
	for petya in range(min_petya, max_petya + 1):
		if vasya > petya:
			num_solutions += 1
			solutions.append((vasya, petya))
print(num_solutions)
for solution in solutions:
	print(f'{solution[0]} {solution[1]}')


(x, y, a, b) = map(int, input().split())
ab = []
for i in range(a, x + 1):
	for j in range(b, min(i, y + 1)):
		ab += [[i, j]]
print(len(ab))
for x in ab:
	print(x[0], end=' ')
	print(x[1])


(x, y, a, b) = map(int, input().split())
if b + 1 > x:
	print(0)
else:
	l1 = []
	for i in range(max(b + 1, a), x + 1):
		for j in range(b, min(i, y + 1)):
			l1.append([i, j])
	print(len(l1))
	for i in l1:
		print(i[0], i[1])


(x, y, a, b) = map(int, input().split())
r = []
for i in range(a, x + 1):
	for j in range(b, y + 1):
		if j < i:
			r.append(str(i) + ' ' + str(j))
print(len(r))
if len(r) > 0:
	print('\n'.join(r))


X = list(map(int, input().split()))
Answers = []
for i in range(X[2], X[0] + 1):
	for j in range(X[3], min(X[1] + 1, i)):
		Answers.append(str(i) + ' ' + str(j))
print(len(Answers))
print(*Answers, sep='\n')


import os
from sys import stdin, stdout

def solve(tc):
	(x, y, a, b) = map(int, stdin.readline().split())
	ans = []
	for i in range(1, 101):
		if i > y or i < b:
			continue
		for j in range(i + 1, 101):
			if j > x or j < a:
				continue
			ans.append([j, i])
	if len(ans) == 0:
		print(0)
	else:
		print(len(ans))
		ans = sorted(ans)
		for elem in ans:
			print(*elem)
tcs = 1
tc = 1
while tc <= tcs:
	solve(tc)
	tc += 1


import math
import sys
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def cdiv(n, k):
	return n // k + (n % k != 0)

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

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

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)
(x, y, a, b) = mi()
r = []
for i in range(a, x + 1):
	for j in range(b, min(i, y + 1)):
		r.append(f'{i} {j}')
print(len(r))
[print(i) for i in r]


def solve(x: int, y: int, a: int, b: int):
	res = []
	for i in range(a, x + 1):
		for j in range(b, y + 1):
			if i > j:
				res.append([i, j])
	print(len(res))
	[print(*i) for i in res]

def main():
	vars = list(map(int, input().split(' ')))
	solve(*vars)
main()


def main():
	(x, y, a, b) = map(int, input().split(' '))
	l = []
	for c in range(a, x + 1):
		for d in range(b, y + 1):
			if c > d:
				l.append((c, d))
	print(len(l))
	for ll in l:
		print('{} {}'.format(*ll))
main()


(x, y, a, b) = map(int, input().split())
counter = 0
ans = []
for i in range(a, x + 1):
	for j in range(b, min(i - 1, y) + 1):
		counter += 1
		ans.append([i, j])
print(counter)
for i in range(counter):
	print(ans[i][0], ans[i][1])


from sys import stdin, stdout
import sys
INF = 100000000000.0
import bisect

def get_int():
	return int(stdin.readline().strip())

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

def get_array():
	return list(map(int, stdin.readline().strip().split()))

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

def op(c):
	return stdout.write(c)
from collections import defaultdict
import math
(x, y, a, b) = get_ints()
if a <= b:
	a = b + 1
ans = []
i = a
while i <= x:
	j = b
	while j <= y:
		if i > j:
			ans.append([i, j])
		j += 1
	i += 1
print(len(ans))
for i in range(len(ans)):
	print(ans[i][0], ans[i][1])


from collections import Counter

def main():
	g = list(map(int, input().split()))
	x = g[0]
	y = g[1]
	a = g[2]
	b = g[3]
	r = []
	c = 0
	for i in range(a, x + 1):
		for j in range(b, y + 1):
			if i > j:
				r.append(str(i) + ' ' + str(j))
				c += 1
	print(c)
	for i in r:
		print(i)
main()


l = list(map(int, input().split()))
x = l[0]
y = l[1]
a = l[2]
b = l[3]
c = 0
k = []
for i in range(a, x + 1):
	for j in range(b, y + 1):
		if i > j:
			c += 1
			s = str(i) + ' ' + str(j)
			k.append(s)
print(c)
for i in range(c):
	print(k[i])


import sys
input = sys.stdin.readline
import math
from collections import defaultdict, deque
ml = lambda : map(int, input().split())
ll = lambda : list(map(int, input().split()))
ii = lambda : int(input())
ip = lambda : list(input())
ips = lambda : input().split()
(x, y, a, b) = ml()
ans = []
for i in range(a, x + 1):
	for j in range(b, min(i, y + 1)):
		ans.append([i, j])
print(len(ans))
for i in ans:
	print(*i)


import sys
import math
import bisect

def solve(x, y, a, b):
	ans = []
	for i in range(a, x + 1):
		for j in range(b, y + 1):
			if i > j:
				ans.append((i, j))
	return ans

def main():
	(x, y, a, b) = map(int, input().split())
	ans = solve(x, y, a, b)
	print(len(ans))
	for i in range(len(ans)):
		print('%d %d' % (ans[i][0], ans[i][1]))
main()


(x, y, a, b) = map(int, input().split())
k = 0
for i in range(max(a, b), x + 1):
	for j in range(b, min(i, y + 1)):
		k += 1
print(k)
for i in range(max(a, b), x + 1):
	for j in range(b, min(i, y + 1)):
		print(i, j)


ar = []
for i in input().split(' '):
	ar.append(int(i))
count = 0
res = []
for i in range(ar[2], ar[0] + 1):
	for j in range(ar[3], ar[1] + 1):
		if i > j:
			count = count + 1
			res.append(str(i) + ' ' + str(j))
print(count)
for i in res:
	print(i)


import sys
import math
(x, y, a, b) = [int(x) for x in sys.stdin.readline().split()]
res = []
for j in range(x, a - 1, -1):
	for i in range(min(j - 1, y), b - 1, -1):
		res.append((j, i))
print(len(res))
for i in res[::-1]:
	print(i[0], i[1])


(x, y, a, b) = map(int, input().split(' '))
c = []
for p in range(a, x + 1):
	for q in range(b, y + 1):
		if q < p:
			c.append((p, q))
print(len(c))
if c != []:
	for p in c:
		print(p[0], p[1])


(x, y, a, b) = [int(i) for i in input().split()]
ans = []
s_a = a
s_b = b
if a <= b:
	s_a = b + 1
	s_b = b
while s_a <= x:
	for i in range(s_b, min(s_a, y + 1)):
		ans.append([s_a, i])
	s_a += 1
print(len(ans))
for i in ans:
	print(i[0], i[1])


(x, y, a, b) = map(int, input().split())
r = []
c = 0
for i in range(a, x + 1):
	for j in range(b, y + 1):
		if i > j:
			r.append([i, j])
print(len(r))
for k in r:
	print(k[0], k[1])


(x, y, a, b) = (int(x) for x in input().split())
val = []
for i in range(max(a, b + 1), x + 1):
	for j in range(b, min(i - 1, y) + 1):
		val.append((i, j))
print(len(val))
for o in val:
	print(o[0], o[1])


(x, y, a, b) = map(int, input().split())
list = []
for i in range(a, x + 1):
	for j in range(b, y + 1):
		if i > j:
			list.append([i, j])
print(len(list))
for pair in list:
	print('{} {}'.format(pair[0], pair[1]))


(x, y, a, b) = input().split(' ')
x = int(x)
y = int(y)
a = int(a)
b = int(b)
n = 0
for i in range(a, x + 1):
	for j in range(b, min(i, y + 1)):
		n += 1
print(n)
for i in range(a, x + 1):
	for j in range(b, min(i, y + 1)):
		print(i, ' ', j)


def headsOrTails(x, y, a, b):
	temp = []
	count = 0
	i = x
	while i >= a:
		j = y
		while j >= b:
			if i > j:
				temp.append([i, j])
			j -= 1
		i -= 1
	print(len(temp))
	temp.sort()
	for i in range(len(temp)):
		print(temp[i][0], ' ', temp[i][1])
(x, y, a, b) = input().split()
headsOrTails(int(x), int(y), int(a), int(b))


(v_max, p_max, v_min, p_min) = map(int, input().strip().split())
possibilities = [(v, p) for v in range(v_min, v_max + 1) for p in range(p_min, p_max + 1) if v > p]
print(len(possibilities))
for game in possibilities:
	print(*game)


(x, y, a, b) = map(int, input().split())
ans = []
for x1 in range(a, x + 1):
	if x1 <= b:
		continue
	for y1 in range(b, y + 1):
		if x1 > y1 and x1 >= a and (y1 >= b):
			ans.append((x1, y1))
print(len(ans))
for x in ans:
	print(*x)


import sys
import math
import collections
import heapq
import decimal
input = sys.stdin.readline
(x, y, a, b) = (int(i) for i in input().split())
ans = []
for i in range(b, y + 1):
	for j in range(max(i + 1, a), x + 1):
		ans.append([j, i])
print(len(ans))
ans.sort()
for i in ans:
	print(*i)