Let's learn about list comprehensions! You are given three integers $x,y$ and $z$ representing the dimensions of a cuboid along with an integer $n$. Print a list of all possible coordinates given by $(i,j,k)$ on a 3D grid where the sum of $i+j+k$ is not equal to $n$. Here, $0\leq i\leq x;0\leq j\le y;0\leq k\leq z$.  Please use list comprehensions rather than multiple loops, as a learning exercise.  

Example 

 $x=1$ 

 $y=1$ 

 $z=2$ 

 $n=3$

All permutations of $[i,j,k]$ are: 

$[[0,0,0],[0,0,1],[0,0,2],[0,1,0],[0,1,[0,1,2],[1,0,0],[1,0,1],[1,0,2],[1,1,0],[1,1],[1,1,2]]$. 

Print an array of the elements that do not sum to $n=3$.  

$[[0,\textbf{0},\textbf{0}],[\textbf{0},\textbf{0},\textbf{1}],[\textbf{0},\textbf{0},\textbf{2}],[\textbf{0},\textbf{1},\textbf{0}],[\textbf{0},\textbf{1},\textbf{1}],[\textbf{1},\textbf{0},\textbf{0}],[\textbf{1},\textbf{0},\textbf{1}],[\textbf{1},\textbf{1},\textbf{0}],[\textbf{1},\textbf{1},\textbf{2}]]$

Input Format

Four integers $x,y,z$ and $n$, each on a separate line. 

Constraints

Print the list in lexicographic increasing order.

Sample Input 0
1
1
1
2

Sample Output 0
[[0, 0, 0], [0, 0, 1], [0, 1, 0], [1, 0, 0], [1, 1, 1]]

Explanation 0

Each variable $x,y$ and $z$ will have values of $\mbox{o}$ or $\mbox{I}$.  All permutations of lists in the form $[i,j,k]=[[0,0,0],[0,0,1],[0,1,0],[0,1,1],[1,0,0],[1,0,1],[1,1,0],[1,1,1]]$. 

Remove all arrays that sum to $n=2$ to leave only the valid permutations.

Sample Input 1
2
2
2
2

Sample Output 1
[[0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 2], [0, 2, 1], [0, 2, 2], [1, 0, 0], [1, 0, 2], [1, 1, 1], [1, 1, 2], [1, 2, 0], [1, 2, 1], [1, 2, 2], [2, 0, 1], [2, 0, 2], [2, 1, 0], [2, 1, 1], [2, 1, 2], [2, 2, 0], [2, 2, 1], [2, 2, 2]]

Difficulty: EASY

Solutions:
(x, y, z, n) = [int(input()) for line in range(4)]
coords = [[i, j, k] for i in range(x + 1) for j in range(y + 1) for k in range(z + 1) if i + j + k != n]
print(coords)


(xr, yr, zr, n) = (int(input()), int(input()), int(input()), int(input()))
print([[x, y, z] for x in range(xr + 1) for y in range(yr + 1) for z in range(zr + 1) if x + y + z != n])


(mx, my, mz) = (int(input()), int(input()), int(input()))
n = int(input())
result = []
for x in range(0, mx + 1):
	for y in range(0, my + 1):
		for z in range(0, mz + 1):
			if x + y + z != n:
				result.append([x, y, z])
print(result)


(X, Y, Z, n) = [int(input()) for i in range(4)]
print([[x, y, z] for x in range(X + 1) for y in range(Y + 1) for z in range(Z + 1) if x + y + z != n])


X = int(input())
Y = int(input())
Z = int(input())
N = int(input())
print([[x, y, z] for x in range(0, X + 1) for y in range(0, Y + 1) for z in range(0, Z + 1) if x + y + z != N])


x = int(input())
y = int(input())
z = int(input())
n = int(input())
print([[xi, yi, zi] for xi in range(x + 1) for yi in range(y + 1) for zi in range(z + 1) if xi + yi + zi != n])


x = int(input())
y = int(input())
z = int(input())
n = int(input())
l = [[x1, y1, z1] for x1 in range(x + 1) for y1 in range(y + 1) for z1 in range(z + 1) if x1 + y1 + z1 != n]
print(l)


x = int(input())
y = int(input())
z = int(input())
n = int(input())
lis = [[i, j, k] for i in range(0, x + 1) for j in range(0, y + 1) for k in range(0, z + 1) if i + j + k != n]
print(lis)


x = int(input())
y = int(input())
z = int(input())
n = int(input())
l = []
for i in range(x + 1):
	for j in range(y + 1):
		for k in range(z + 1):
			if i + j + k != n:
				l.append([i, j, k])
print(l)


from sys import stdin
X = int(stdin.readline())
Y = int(stdin.readline())
Z = int(stdin.readline())
N = int(stdin.readline())
ans = []
for i in range(0, X + 1):
	for j in range(0, Y + 1):
		for k in range(0, Z + 1):
			if i + j + k != N:
				point = [i, j, k]
				ans.append(point)
print(ans)


X = int(input())
Y = int(input())
Z = int(input())
N = int(input())
X += 1
Y += 1
Z += 1
tmp_list = [[x, y, z] for x in range(X) for y in range(Y) for z in range(Z) if x + y + z != N]
print(tmp_list)


(x, y, z, n) = [int(input()) for _ in range(4)]
print([[x_i, y_i, z_i] for x_i in range(x + 1) for y_i in range(y + 1) for z_i in range(z + 1) if x_i + y_i + z_i != n])


(X, Y, Z, N) = (int(input()), int(input()), int(input()), int(input()))
print([[x, y, z] for x in range(X + 1) for y in range(Y + 1) for z in range(Z + 1) if x + y + z != N])


a = int(input())
b = int(input())
c = int(input())
n = int(input())
lis = [[x, y, z] for x in range(a + 1) for y in range(b + 1) for z in range(c + 1) if x + y + z != n]
print(lis)


x = int(input())
y = int(input())
z = int(input())
n = int(input())
re = [[i, j, k] for i in range(x + 1) for j in range(y + 1) for k in range(z + 1) if i + j + k != n]
print(re)


x = int(input())
y = int(input())
z = int(input())
n = int(input())
l = []
for a in range(x + 1):
	for b in range(y + 1):
		for c in range(z + 1):
			if a + b + c != n:
				li = []
				li.append(a)
				li.append(b)
				li.append(c)
				l.append(li)
print(l)


def main():
	x = int(input())
	y = int(input())
	z = int(input())
	n = int(input())
	ans = [[xi, yi, zi] for xi in range(x + 1) for yi in range(y + 1) for zi in range(z + 1) if xi + yi + zi != n]
	print(ans)
main()


ans = []
X = int(input())
Y = int(input())
Z = int(input())
N = int(input())
for i in range(X + 1):
	for j in range(Y + 1):
		for k in range(Z + 1):
			if i + j + k != N:
				ans.append([i, j, k])
print(ans)


lis = []
x = input()
y = input()
z = input()
n = input()
cnt = 0
print('[', end='')
for a in range(int(x) + 1):
	for b in range(int(y) + 1):
		for c in range(int(z) + 1):
			if not int(a) + int(b) + int(c) == int(n):
				lis.append('[%d, %d, %d], ' % (a, b, c))
				cnt = int(cnt) + 1
i = 0
if not int(cnt) == 0:
	lis[int(cnt) - 1] = '[%d, %d, %d]' % (a, b, c)
while int(i) < int(cnt):
	print(lis[i], end='')
	i = int(i) + 1
print(']', end='')


lst = []
xin = int(input())
yin = int(input())
zin = int(input())
n = int(input())
lst = [[x, y, z] for x in range(xin + 1) for y in range(yin + 1) for z in range(zin + 1) if x + y + z != n]
print(sorted(lst))


X = int(input())
Y = int(input())
Z = int(input())
N = int(input())
xi = [i for i in range(0, X + 1)]
yi = [i for i in range(0, Y + 1)]
zi = [i for i in range(0, Z + 1)]
lip = [[x, y, z] for x in xi for y in yi for z in zi if x + y + z != N]
print(lip)


x = [i for i in range(int(input()) + 1)]
y = [i for i in range(int(input()) + 1)]
z = [i for i in range(int(input()) + 1)]
n = int(input())
answer = []
for xi in x:
	for yi in y:
		for zi in z:
			sum = xi + yi + zi
			if sum != n:
				ans = [xi, yi, zi]
				answer.append(ans)
print(answer)


x = int(input())
y = int(input())
z = int(input())
n = int(input())
L = [[i, j, k] for i in range(x + 1) for j in range(y + 1) for k in range(z + 1) if i + j + k != n]
print(L)


x = int(input())
y = int(input())
z = int(input())
n = int(input())
list = []
for i in range(x + 1):
	for j in range(y + 1):
		for k in range(z + 1):
			if i + j + k != n:
				list.append([i, j, k])
print(list)


x = int(input())
y = int(input())
z = int(input())
n = int(input())
res = []
for i in range(0, x + 1):
	for j in range(0, y + 1):
		for k in range(0, z + 1):
			if i + j + k == n:
				continue
			l = [i, j, k]
			res.append(l)
print(res)


X = int(input()) + 1
Y = int(input()) + 1
Z = int(input()) + 1
N = int(input())
print([[x, y, z] for x in range(X) for y in range(Y) for z in range(Z) if x + y + z != N])


x = int(input())
y = int(input())
z = int(input())
N = int(input())
ans = []
for i in range(x + 1):
	for j in range(y + 1):
		for k in range(z + 1):
			if i + j + k != N:
				ans.append([i, j, k])
print(ans)


x = int(input())
y = int(input())
z = int(input())
n = int(input())
r = []
for i in range(x + 1):
	for j in range(y + 1):
		for k in range(z + 1):
			if i + j + k != n:
				r.append([i, j, k])
print(r)


def gen(x, y, z, n):
	for i in range(x + 1):
		for j in range(y + 1):
			for k in range(z + 1):
				if i + j + k == n:
					continue
				yield [i, j, k]
x = int(input())
y = int(input())
z = int(input())
n = int(input())
l = list(gen(x, y, z, n))
print(l)


x = input()
x = x.rstrip()
x = int(x)
y = input()
y.rstrip()
y = int(y)
z = input()
z = z.rstrip()
z = int(z)
n = input()
n = n.rstrip()
n = int(n)
answer_list = []
for i in range(0, x + 1):
	for j in range(0, y + 1):
		for k in range(0, z + 1):
			if i + j + k != n:
				answer_list = answer_list + [[i, j, k]]
print(answer_list)


x = int(input())
y = int(input())
z = int(input())
d = int(input())
li = [[a, b, c] for a in range(x + 1) for b in range(y + 1) for c in range(z + 1) if a + b + c != d]
print(li)


xr = int(input()) + 1
yr = int(input()) + 1
zr = int(input()) + 1
n = int(input())
print([[x, y, z] for x in range(xr) for y in range(yr) for z in range(zr) if x + y + z != n])


X = int(input())
Y = int(input())
Z = int(input())
N = int(input())
ans = [[x, y, z] for x in range(X + 1) for y in range(Y + 1) for z in range(Z + 1) if x + y + z != N]
print(ans)


X = int(input())
Y = int(input())
Z = int(input())
N = int(input())
result = []
for xi in range(0, X + 1):
	for yi in range(0, Y + 1):
		for zi in range(0, Z + 1):
			if xi + yi + zi != N:
				result.append([xi, yi, zi])
print(result)


def __starting_point():
	x = int(input())
	y = int(input())
	z = int(input())
	n = int(input())
	print([[i, j, k] for i in range(x + 1) for j in range(y + 1) for k in range(z + 1) if i + j + k != n])
__starting_point()


x = int(input())
y = int(input())
z = int(input())
n = int(input())
results = []
for i in range(0, x + 1):
	for j in range(0, y + 1):
		[results.append([i, j, k]) for k in range(0, z + 1) if i + j + k != n]
print(results)


x = int(input())
y = int(input())
z = int(input())
n = int(input())
print([[i, j, k] for i in range(x + 1) for j in range(y + 1) for k in range(z + 1) if i + j + k != n])


xRange = range(int(input()) + 1)
yRange = range(int(input()) + 1)
zRange = range(int(input()) + 1)
sum = int(input())
solutions = []
for x in xRange:
	for y in yRange:
		for z in zRange:
			if x + y + z != sum:
				solutions.append([x, y, z])
print(solutions)


X = int(input()) + 1
Y = int(input()) + 1
Z = int(input()) + 1
N = int(input())
print([[x, y, z] for x in range(X) for y in range(Y) for z in range(Z) if sum([x, y, z]) != N])


result = []
x = int(input())
y = int(input())
z = int(input())
n = int(input())
tempx = 0
tempy = 0
tempz = 0
while tempx <= x:
	while tempy <= y:
		while tempz <= z:
			if tempx + tempy + tempz != n:
				result.append([tempx, tempy, tempz])
			tempz += 1
		tempz = 0
		tempy += 1
	tempy = 0
	tempx += 1
print(result)


values = [int(input()) for x in range(3)]
n = int(input())
print(sorted(list((list(x) for x in set([(x, y, z) for x in range(values[0] + 1) for y in range(values[1] + 1) for z in range(values[2] + 1) if x + y + z != n])))))


X = int(input())
Y = int(input())
Z = int(input())
N = int(input())
lis = [[x, y, z] for x in range(X + 1) for y in range(Y + 1) for z in range(Z + 1) if x + y + z != N]
print(lis)


x = int(input())
y = int(input())
z = int(input())
n = int(input())
l = []
for i in range(0, x + 1):
	for j in range(0, y + 1):
		for k in range(0, z + 1):
			p = []
			if i + j + k != n:
				p.append(i)
				p.append(j)
				p.append(k)
				l.append(p)
print(l)


x = eval(input())
y = eval(input())
z = eval(input())
n = eval(input())
l = list()
for i in range(x + 1):
	for j in range(y + 1):
		for k in range(z + 1):
			if i + j + k != n:
				k1 = [i, j, k]
				l.append(k1)
print(l)


(x, y, z, n) = (int(int(input())) for _ in range(4))
print([[i, j, k] for i in range(x + 1) for j in range(y + 1) for k in range(z + 1) if i + j + k != n])


x = int(input())
y = int(input())
z = int(input())
n = int(input())
output = [[X, Y, Z] for X in range(x + 1) for Y in range(y + 1) for Z in range(z + 1) if X + Y + Z != n]
print(output)


x = int(input())
y = int(input())
z = int(input())
N = int(input())
arr = [[X, Y, Z] for X in range(x + 1) for Y in range(y + 1) for Z in range(z + 1) if X + Y + Z != N]
print(arr)


def main():
	a = int(input())
	b = int(input())
	c = int(input())
	n = int(input())
	list = []
	for x in range(a + 1):
		for y in range(b + 1):
			for z in range(c + 1):
				sum = x + y + z
				if sum != n:
					l1 = [x, y, z]
					list.append(l1)
	print(list)
main()


(x, y, z, n) = [int(input()) for i in range(4)]
r = [[a, b, c] for a in range(x + 1) for b in range(y + 1) for c in range(z + 1) if a + b + c != n]
print(r)


A = int(input())
B = int(input())
C = int(input())
D = int(input())
print(list(([a, b, c] for a in range(0, A + 1) for b in range(0, B + 1) for c in range(0, C + 1) if a + b + c != D)))


x = int(input())
y = int(input())
z = int(input())
n = int(input())
lis = [[i, j, k] for i in range(x + 1) for j in range(y + 1) for k in range(z + 1) if i + j + k != n]
print(lis)


x = input()
y = input()
z = input()
N = input()
grid = []
for i in range(int(x) + 1):
	for j in range(int(y) + 1):
		for k in range(int(z) + 1):
			if i + j + k != int(N):
				grid.append([i, j, k])
print(grid)


x = int(input())
y = int(input())
z = int(input())
n = int(input())
print([[q, w, c] for q in range(x + 1) for w in range(y + 1) for c in range(z + 1) if q + w + c != n])


x = int(input())
y = int(input())
z = int(input())
n = int(input())
ans = []
for xi in range(x + 1):
	for yi in range(y + 1):
		for zi in range(z + 1):
			if xi + yi + zi == n:
				continue
			ans.append([xi, yi, zi])
print(ans)


ret = []
x = int(input())
y = int(input())
z = int(input())
n = int(input())
for i in range(0, x + 1):
	for j in range(0, y + 1):
		for k in range(0, z + 1):
			if i + j + k != n:
				ret.append([i, j, k])
print(ret)


x = int(input())
y = int(input())
z = int(input())
n = int(input())
data = [[a, b, c] for a in range(x + 1) for b in range(y + 1) for c in range(z + 1) if a + b + c != n]
print(data)


x = int(input())
y = int(input())
z = int(input())
n = int(input())
xs = range(x + 1)
ys = range(y + 1)
zs = range(z + 1)
result = []
for i in xs:
	for j in ys:
		for k in zs:
			result.append([i, j, k])
result = [[i, j, k] for [i, j, k] in result if i + j + k != n]
print(result)


x = int(input())
y = int(input())
z = int(input())
n = int(input())
print([[a, b, c] for a in range(0, x + 1) for b in range(0, y + 1) for c in range(0, z + 1) if a + b + c != n])


res = []
x = int(input())
y = int(input())
z = int(input())
n = int(input())
for i in range(x + 1):
	for j in range(y + 1):
		for k in range(z + 1):
			if i + j + k != n:
				x = [i, j, k]
				res.append(x)
print(res)


(X, Y, Z, N) = (int(input()) for _ in range(4))
print([[x, y, z] for x in range(X + 1) for y in range(Y + 1) for z in range(Z + 1) if x + y + z != N])


x = int(input())
y = int(input())
z = int(input())
n = int(input())
results = []
for x1 in range(x + 1):
	for y1 in range(y + 1):
		for z1 in range(z + 1):
			if x1 + y1 + z1 != n:
				results.append([x1, y1, z1])
print(results)


x = int(input())
y = int(input())
z = int(input())
n = int(input())
ans = list()
for i in range(0, x + 1):
	for j in range(0, y + 1):
		for k in range(0, z + 1):
			if i + j + k != n:
				ans.append([i, j, k])
print(ans)


import sys

def freopen(f, option, stream):
	import os
	oldf = open(f, option)
	oldfd = oldf.fileno()
	newfd = stream.fileno()
	os.close(newfd)
	os.dup2(oldfd, newfd)
x = int(input())
y = int(input())
z = int(input())
n = int(input())
x += 1
y += 1
z += 1
print([[i, j, k] for i in range(x) for j in range(y) for k in range(z) if i + j + k != n])


from sys import stdin

def populate_lists(x, y, z, n):
	total_list = []
	for x_i in range(x + 1):
		for y_i in range(y + 1):
			for z_i in range(z + 1):
				if x_i + y_i + z_i != n:
					total_list.append([x_i, y_i, z_i])
	return total_list

def main():
	x = int(stdin.readline())
	y = int(stdin.readline())
	z = int(stdin.readline())
	n = int(stdin.readline())
	all_points = populate_lists(x, y, z, n)
	all_points.sort()
	print(all_points)
main()


x = int(input())
y = int(input())
z = int(input())
n = int(input())
lis = [[a, b, c] for a in range(0, x + 1) for b in range(0, y + 1) for c in range(0, z + 1) if a + b + c != n]
print(lis)


xx = int(input())
yy = int(input())
zz = int(input())
nn = int(input())
i = 0
answer = []
while i <= xx:
	j = 0
	while j <= yy:
		k = 0
		while k <= zz:
			tmp = i + j + k
			if tmp != nn:
				lst = []
				lst.append(i)
				lst.append(j)
				lst.append(k)
				answer.append(lst)
			k = k + 1
		j = j + 1
	i = i + 1
answer.sort()
print(answer)


X = int(input()) + 1
Y = int(input()) + 1
Z = int(input()) + 1
N = int(input())
li = [[x, y, z] for x in range(X) for y in range(Y) for z in range(Z) if x + y + z != N]
print(li)


x = int(input())
y = int(input())
z = int(input())
n = int(input())
lst = [[a, b, c] for a in range(x + 1) for b in range(y + 1) for c in range(z + 1) if a + b + c != n]
print(lst)


import sys
x = int(sys.stdin.readline())
y = int(sys.stdin.readline())
z = int(sys.stdin.readline())
n = int(sys.stdin.readline())
result = []
t_list = []
for i in range(0, x + 1):
	for j in range(0, y + 1):
		for k in range(0, z + 1):
			if i + j + k != n:
				result.append([i, j, k])
print(result)


x = int(input())
y = int(input())
z = int(input())
n = int(input())
result = []
for x in range(x + 1):
	for y in range(y + 1):
		for z in range(z + 1):
			if x + y + z != n:
				result.append([x, y, z])
print(result)


X = int(input())
Y = int(input())
Z = int(input())
N = int(input())
print([[x, y, z] for x in range(X + 1) for y in range(Y + 1) for z in range(Z + 1) if x + y + z != N])


x = int(input())
y = int(input())
z = int(input())
n = int(input())
re = []
for i in range(x + 1):
	for j in range(y + 1):
		for k in range(z + 1):
			if i + j + k != n:
				a = [i, j, k]
				re.append(a)
print(re)


x = int(input())
y = int(input())
z = int(input())
n = int(input())
print([[a, b, c] for a in range(x + 1) for b in range(y + 1) for c in range(z + 1) if a + b + c != n])


ar = []
x = int(input())
y = int(input())
z = int(input())
n = int(input())
for j in range(x + 1):
	for k in range(y + 1):
		for l in range(z + 1):
			if j + k + l != n:
				sub_ar = [j, k, l]
				ar.append(sub_ar)
print(ar)


x = int(input())
y = int(input())
z = int(input())
n = int(input())
a = []
for i in range(0, x + 1):
	for j in range(0, y + 1):
		for k in range(0, z + 1):
			row = []
			if i + j + k != n:
				row.append(i)
				row.append(j)
				row.append(k)
				a.append(row)
print(a)


x = int(input())
y = int(input())
z = int(input())
n = int(input())

def generateAllLists(a, b, c, n):
	for i1 in range(0, a + 1):
		for i2 in range(0, b + 1):
			for i3 in range(0, c + 1):
				if i1 + i2 + i3 == n:
					continue
				yield [i1, i2, i3]
generatedList = generateAllLists(x, y, z, n)
result = [i for i in generatedList]
print(result)


x = int(input())
y = int(input())
z = int(input())
n = int(input())
print([[x1, y1, z1] for x1 in range(x + 1) for y1 in range(y + 1) for z1 in range(z + 1) if x1 + y1 + z1 != n])


X = int(input()) + 1
Y = int(input()) + 1
Z = int(input()) + 1
N = int(input())
lst = []
for x in range(0, X):
	for y in range(0, Y):
		for z in range(0, Z):
			if x + y + z != N:
				lst.append([x, y, z])
print(lst)


x = int(input())
y = int(input())
u = int(input())
n = int(input())
b = []
for x1 in range(0, x + 1):
	for y1 in range(0, y + 1):
		for u1 in range(0, u + 1):
			if x1 + y1 + u1 != n:
				b.append([x1, y1, u1])
print(b)


x = int(input())
y = int(input())
z = int(input())
n = int(input())
res = []
for i in range(0, x + 1):
	for j in range(0, y + 1):
		for k in range(0, z + 1):
			if i + j + k != n:
				res.append([i, j, k])
print(res)


(x, y, z, n) = (int(input()), int(input()), int(input()), int(input()))
L = []
for xi in range(x + 1):
	for yi in range(y + 1):
		for zi in range(z + 1):
			if xi + yi + zi != n:
				L.append([xi, yi, zi])
print(L)


X = int(input())
Y = int(input())
Z = int(input())
N = int(input())
list = []
for i in range(0, X + 1):
	for j in range(0, Y + 1):
		for k in range(0, Z + 1):
			if k > Z:
				break
			if i + j + k == N:
				continue
			else:
				list.append([i, j, k])
		if j > Y:
			break
	if i > X:
		break
print(list)


X = int(input())
Y = int(input())
Z = int(input())
n = int(input())
res = [[x, y, z] for x in range(X + 1) for y in range(Y + 1) for z in range(Z + 1) if x + y + z != n]
print(res)


x = int(input())
y = int(input())
z = int(input())
N = int(input())
coordinates = [[a, b, c] for a in range(x + 1) for b in range(y + 1) for c in range(z + 1) if a + b + c != N]
print(coordinates)


xr = range(int(input()) + 1)
yr = range(int(input()) + 1)
zr = range(int(input()) + 1)
n = int(input())
arr = [[x, y, z] for x in xr for y in yr for z in zr if x + y + z != n]
print(arr)


def read_int():
	return int(input())
(x, y, z, n) = [read_int() for i in range(4)]
cuboids = [[xi, yi, zi] for xi in range(x + 1) for yi in range(y + 1) for zi in range(z + 1) if sum([xi, yi, zi]) != n]
print(cuboids)


a = int(input())
b = int(input())
c = int(input())
n = int(input())
out = []
for i in range(0, a + 1):
	for j in range(0, b + 1):
		for k in range(0, c + 1):
			if i + j + k != n:
				out.append([i, j, k])
print(out)


x = int(input())
y = int(input())
z = int(input())
n = int(input())
x = list(range(x + 1))
y = list(range(y + 1))
z = list(range(z + 1))
a = [[i, j, k] for i in x for j in y for k in z if i + j + k != n]
print(a)


i = int(input().strip())
j = int(input().strip())
k = int(input().strip())
n = int(input().strip())
ans = [[x, y, z] for x in range(i + 1) for y in range(j + 1) for z in range(k + 1) if x + y + z != n]
print(ans)


s = []
for i in range(4):
	num = int(input())
	s.append(num)
L = [[x, y, z] for x in range(s[0] + 1) for y in range(s[1] + 1) for z in range(s[2] + 1) if x + y + z != s[3]]
print(L)


x = int(input())
y = int(input())
z = int(input())
n = int(input())
result = [[a, b, c] for a in range(0, x + 1) for b in range(0, y + 1) for c in range(0, z + 1) if a + b + c != n]
print(result)


from sys import stdin

def get_coordinates():
	coord = []
	for i in range(4):
		coord.append(int(stdin.readline()))
	return coord

def main():
	(*coords, n) = get_coordinates()
	print([[x, y, z] for x in range(coords[0] + 1) for y in range(coords[1] + 1) for z in range(coords[2] + 1) if x + y + z != n])
main()


import sys
if sys.version_info[0] >= 3:
	raw_input = input

def dfs(v, d, a, n):
	if d == len(v):
		if sum(a) != n:
			yield a
	else:
		for i in range(v[d] + 1):
			for e in dfs(v, d + 1, a + [i], n):
				yield e
v = [int(raw_input()) for i in range(4)]
n = v.pop()
print(list(dfs(v, 0, [], n)))


x = int(input())
y = int(input())
z = int(input())
n = int(input())
lst = []
for i in range(x + 1):
	for j in range(y + 1):
		for k in range(z + 1):
			if i + j + k != n:
				lst.append([i, j, k])
print(lst)