AtCoder Grand Contest 016 - +/- Rectangle

You are given four integers: H, W, h and w (1 ≤ h ≤ H, 1 ≤ w ≤ W). Determine whether there exists a matrix such that all of the following conditions are held, and construct one such matrix if the answer is positive:

* The matrix has H rows and W columns.
* Each element of the matrix is an integer between -10^9 and 10^9 (inclusive).
* The sum of all the elements of the matrix is positive.
* The sum of all the elements within every subrectangle with h rows and w columns in the matrix is negative.

Constraints

* 1 ≤ h ≤ H ≤ 500
* 1 ≤ w ≤ W ≤ 500

Input

Input is given from Standard Input in the following format:


H W h w


Output

If there does not exist a matrix that satisfies all of the conditions, print `No`.

Otherwise, print `Yes` in the first line, and print a matrix in the subsequent lines in the following format:


a_{11} ... a_{1W}
:
a_{H1} ... a_{HW}


Here, a_{ij} represents the (i,\ j) element of the matrix.

Examples

Input

3 3 2 2


Output

Yes
1 1 1
1 -4 1
1 1 1


Input

2 4 1 2


Output

No


Input

3 4 2 3


Output

Yes
2 -5 8 7
3 -5 -4 -5
2 1 -1 7

Source: atcoder | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
import sys
input = sys.stdin.buffer.readline
from collections import defaultdict

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

def main():
	(H, W, h, w) = getlist()
	L = [[1] * W for i in range(H)]
	if h * w != 1:
		x = (10 ** 9 - 1) // (h * w - 1)
		for i in range(H):
			for j in range(W):
				L[i][j] = x
	for i in range(H // h):
		for j in range(W // w):
			L[(i + 1) * h - 1][(j + 1) * w - 1] = -10 ** 9
	s = 0
	for i in range(H):
		for j in range(W):
			s += L[i][j]
	if s < 0:
		print('No')
		return
	print('Yes')
	for i in range(H):
		print(' '.join(list(map(str, L[i]))))
main()


(H, W, h, w) = map(int, input().split())

def solve(H, W, h, w):
	if W % w == 0 and H % h == 0:
		return (False, [])
	if W % w == 0:
		return (True, solve_vertical(H, W, h, w))
	return (True, solve_horizontal(H, W, h, w))

def solve_horizontal(H, W, h, w):
	return [solve_horizontal_core(W, w)] * H

def solve_horizontal_core(W, w):
	(m, r) = divmod(W, w)
	row = [0] * W
	row[0] = m + 1
	row[w - 1] = -m - 2
	for i in range(w, W):
		row[i] = row[i - w]
	return row

def solve_vertical(H, W, h, w):
	col = solve_horizontal_core(H, h)
	m = []
	for c in col:
		m.append([c] * W)
	return m
(yesno, mat) = solve(H, W, h, w)
if yesno:
	print('Yes')
	for row in mat:
		print(*row)
else:
	print('No')


(H, W, h, w) = list(map(int, input().split()))
INF = 10 ** 10
mat = [[1000 for _ in range(H)] for _ in range(W)]
val = -h * w * 1000 + 999
for h_new in range(h - 1, H, h):
	for w_new in range(w - 1, W, w):
		mat[w_new][h_new] = val
if sum((sum((mat[j][i] for i in range(H))) for j in range(W))) < 0:
	print('No')
else:
	print('Yes')
	for i in range(H):
		for j in range(W):
			print(mat[j][i], end=' ')
		print('')


from sys import exit
(H, W, h, w) = map(int, input().split())
if not H % h and (not W % w):
	print('No')
	exit()
print('Yes')
G = [[1000] * W for _ in range(H)]
if H % h:
	for i in range(H // h):
		t = (i + 1) * h - 1
		for j in range(W):
			G[t][j] = -(h - 1) * 1000 - 1
else:
	for i in range(W // w):
		t = (i + 1) * w - 1
		for j in range(H):
			G[j][t] = -(w - 1) * 1000 - 1
for g in G:
	print(*g)


(H, W, h, w) = map(int, input().split())
p = (10 ** 9 - 1) // max(h * w - 1, 1)
m = p * (h * w - 1) + 1
vec = [[p for i in range(W + 1)] for j in range(H + 1)]
sm = 0
for i in range(1, H + 1):
	for j in range(1, W + 1):
		if i % h == 0 and j % w == 0:
			vec[i][j] = -m
		sm += vec[i][j]
if sm <= 0:
	print('No')
else:
	print('Yes')
	for i in range(1, H + 1):
		for j in range(1, W + 1):
			print(vec[i][j], end=' \n'[j == W])


import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10 ** 9))
write = lambda x: sys.stdout.write(x + '\n')
(H, W, h, w) = map(int, input().split())
v = [[0] * W for _ in range(H)]
if H % h == 0 and W % w == 0:
	print('No')
else:
	for i in range(H // h):
		for j in range(W // w):
			v[(i + 1) * h - 1][(j + 1) * w - 1] = -10 ** 9
	for i in range(H // h + 1):
		for j in range(W // w + 1):
			if i * h < H and j * w < W:
				v[i * h][j * w] = 10 ** 9 - 1
	ss = sum((sum(vv) for vv in v))
	if ss > 0:
		print('Yes')
		write('\n'.join((' '.join(map(str, vv)) for vv in v)))
	else:
		print('No')


(H, W, h, w) = map(int, input().split())
if H % h == 0 and W % w == 0:
	print('No')
	exit()
rem = H * W - (H - H % h) * (W - W % w)
x = H // h * W // w // rem + 1
a = [[x] * W for _ in range(H)]
for i in range(h - 1, H, h):
	for j in range(w - 1, W, w):
		a[i][j] = -(h * w - 1) * x - 1
print('Yes')
for row in a:
	print(*row)


(H, W, h, w) = map(int, input().split())
lis = [[600] * W for i in range(H)]
for i in range(H):
	for j in range(W):
		if i % h == h - 1 and j % w == w - 1:
			lis[i][j] = -600 * (h * w - 1) - 1
s = 0
for i in range(H):
	s += sum(lis[i])
if s <= 0:
	print('No')
else:
	print('Yes')
	for i in lis:
		print(' '.join(map(str, i)))


(H, W, h, w) = map(int, input().split())
if H % h == 0 and W % w == 0:
	print('No')
	quit()
else:
	print('Yes')
m = -10 ** 9
p = (-m - 1) // (h * w - 1)
ans = [[m if i % h == 0 and j % w == 0 else p for j in range(1, W + 1)] for i in range(1, H + 1)]
for i in ans:
	print(' '.join(map(str, i)))


(H, W, h, w) = map(int, input().split())
if H % h == 0 and W % w == 0:
	print('No')
else:
	print('Yes')
	ans = [[None] * W for i in range(H)]
	for i in range(H):
		for j in range(W):
			if i % h == h - 1 and j % w == w - 1:
				ans[i][j] = -1 * 1000 * (h * w - 1) - 1
			else:
				ans[i][j] = 1000
	for i in ans:
		print(*i)


import sys
(H, W, h, w) = map(int, input().split())
rh = H % h
rw = W % w
qh = H // h
qw = W // w
if rh == 0 and rw == 0:
	print('No')
	sys.exit()
print('Yes')
dp = [[0] * W for i in range(H)]
for i in range(0, H, h):
	for j in range(0, W, w):
		dp[i][j] = 10 ** 9 - 1
for i in range(h - 1, H, h):
	for j in range(w - 1, W, w):
		dp[i][j] = -10 ** 9
for i in range(H):
	print(' '.join(map(str, dp[i])))


import sys
input = sys.stdin.readline
(H, W, h, w) = map(int, input().split())
unit = 10 ** 9 - 1
c = H * W
for i in range(h - 1, H, h):
	for j in range(w - 1, W, w):
		c -= 1
if c == 0:
	print('No')
	exit(0)
res = [[unit // c] * W for _ in range(H)]
for i in range(h - 1, H, h):
	for j in range(w - 1, W, w):
		res[i][j] = -(unit // c * (h * w - 1) + 1)
if sum([sum(r) for r in res]) > 0:
	print('Yes')
	for r in res:
		print(*r)
else:
	print('No')


(H, W, a, b) = map(int, input().split())
if H % a or W % b:
	print('Yes')
	accAs = [0]
	if H % a:
		(N, c) = (H, a)
		k = -(-H // a)
	else:
		(N, c) = (W, b)
		k = -(-W // b)
	for i in range(k):
		accAs += [k - i] * (c - 1) + [-i - 1]
	As = []
	for i in range(N):
		As.append(accAs[i + 1] - accAs[i])
	if H % a:
		for i in range(H):
			print(' '.join(map(str, [As[i]] * W)))
	else:
		for _ in range(H):
			print(*As)
else:
	print('No')


(H, W, h, w) = map(int, input().split())
if H % h == 0 and W % w == 0:
	print('No')
	exit()
big = 1000
mul = h * w - 1
print('Yes')
for y in range(1, H + 1):
	arr = []
	for x in range(1, W + 1):
		if y % h == 0 and x % w == 0:
			arr.append(-(big * mul + 1))
		else:
			arr.append(big)
	print(' '.join(map(str, arr)))


(H, W, h, w) = map(int, input().split())
p = 1000
if H % h > 0 or W % w > 0:
	print('Yes')
	a = [[p] * W for i in range(H)]
	for i in range(h - 1, H, h):
		for j in range(w - 1, W, w):
			a[i][j] = -p * (h * w - 1) - 1
	for i in range(H):
		print(' '.join(map(str, a[i])))
else:
	print('No')


(H, W, h, w) = map(int, input().split())
if H % h == 0 and W % w == 0:
	print('No')
	exit()
print('Yes')
n = 1000
if W % w:
	m = -((w - 1) * n + 1)
	row = [m if i % w == w - 1 else n for i in range(W)]
	for i in range(H):
		print(*row)
else:
	m = -((h - 1) * n + 1)
	for i in range(H):
		if i % h == h - 1:
			print(*[m] * W)
		else:
			print(*[n] * W)


def examA():
	Alpha = [chr(i) for i in range(97, 97 + 26)]
	S = SI()
	N = len(S)
	ans = -1
	for i in range(N):
		for s in Alpha:
			cur = [s for s in S]
			for l in range(i):
				for k in range(N - 1):
					if cur[k + 1] == s:
						cur[k] = s
			if len(Counter(cur[:N - i])) == 1:
				ans = i
				break
		if ans >= 0:
			break
	print(ans)
	return

def examB():
	N = I()
	A = LI()
	d = defaultdict(int)
	for a in A:
		d[a] += 1
	l = min(d)
	r = max(d)
	ans = 'Yes'
	if l >= N:
		ans = 'No'
	if r - l > 1:
		ans = 'No'
	if d[l] > l:
		ans = 'No'
	if (r - d[l]) * 2 + d[l] > N:
		ans = 'No'
	if r == l and (N - l == 1 or N // 2 >= l):
		ans = 'Yes'
	print(ans)
	return

def examC():
	(H, W, h, w) = LI()
	judge = H % h + W % w
	if judge == 0:
		print('No')
		return
	print('Yes')
	now = H // h + W // w
	neg = -(h * w - 1) * now - 1
	A = [[now] * W for _ in range(H)]
	for i in range(1, 1 + H // h):
		for j in range(1, 1 + W // w):
			A[i * h - 1][j * w - 1] = neg
	for v in A:
		print(' '.join(map(str, v)))
	return
import sys, copy, bisect, itertools, heapq, math
from heapq import heappop, heappush, heapify
from collections import Counter, defaultdict, deque

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

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

def LSI():
	return list(map(str, sys.stdin.readline().split()))

def LS():
	return sys.stdin.readline().split()

def SI():
	return sys.stdin.readline().strip()
mod = 10 ** 9 + 7
inf = float('inf')
examC()


(H, W, h, w) = map(int, input().split())
if H % h == 0 and W % w == 0:
	print('No')
	exit()
print('Yes')
Base = [[0] * w for i in range(h)]
Base[0][0] = 10000000
Base[-1][-1] = -10000001
M = [[0] * W for i in range(H)]
for i in range(H):
	for j in range(W):
		M[i][j] = str(Base[i % h][j % w])
for i in range(H):
	print(' '.join(M[i]))


def solve(W, w):
	A = [1] * W
	for i in range(W - 1, w - 1, -1):
		A[i - w] = A[i] + 1
	A[w - 1::w] = [-i for i in range(1, W // w + 1)]
	for i in range(W - 2, -1, -1):
		A[i + 1] -= A[i]
	return A
(H, W, h, w) = map(int, input().split())
if W % w:
	print('Yes')
	A = solve(W, w)
	for _ in range(H):
		print(*A)
elif H % h:
	print('Yes')
	A = solve(H, h)
	for i in range(H):
		print(*[A[i]] * W)
else:
	print('No')


def main():
	(H, W, h, w) = map(int, input().split())
	p = 4000
	q = h * w - 1
	a = [[p] * W for _ in [0] * H]
	for i in range(H // h):
		for j in range(W // w):
			a[(i + 1) * h - 1][(j + 1) * w - 1] = -p * q - 1
	if sum([sum(i) for i in a]) <= 0:
		print('No')
	else:
		print('Yes')
		for i in a:
			print(*i)
main()


(H, W, h, w) = map(int, input().split())
if H % h == 0 and W % w == 0:
	print('No')
else:
	print('Yes')
	ans = [[1000] * W for i in range(H)]
	num = 0
	for i in range(h - 1, H, h):
		for j in range(w - 1, W, w):
			ans[i][j] = -(h * w - 1) * 1000 - 1
			num += 1
	for nu in ans:
		print(' '.join(map(str, nu)))


(H, W, h, w) = map(int, input().split())
if H % h or W % w:
	print('Yes')
	a = 10 ** 9 // (h * w)
	ans = [[a] * W for _ in [0] * H]
	for i in range(h - 1, H, h):
		for j in range(w - 1, W, w):
			ans[i][j] = -a * (h * w - 1) - 1
	for out in ans:
		print(*out)
else:
	print('No')


(H, W, h, w) = map(int, input().split())
if H % h == W % w == 0:
	print('No')
	exit(0)
print('Yes')
f = 0
(a, b) = (W, w)
if not W % w:
	f = 1
	(a, b) = (H, h)
l = [0] * (a + 1)
l[1] = 10 ** 6
for i in range(2, a + 1):
	if i >= b:
		l[i] = l[i - b] - 1
	else:
		l[i] = l[i - 1] - 1
assert l[-1] > 0
g = [l[i + 1] - l[i] for i in range(a)]
if f:
	for x in g:
		print(*[x] * W)
else:
	for _ in range(H):
		print(*g)


(H, W, h, w) = map(int, input().split())
if H % h == 0 and W % w == 0:
	print('No')
	quit()
print('Yes')

def solve(H, W, h, w):
	S = [0] * (W + 1)
	S[W % w] = 1 + W // w
	for i in range(w, W + 1):
		S[i] = S[i - w] - 1
	return [[S[i + 1] - S[i] for i in range(W)]] * H
if W % w != 0:
	A = solve(H, W, h, w)
else:
	A = [r for r in zip(*solve(W, H, w, h))]
for a in A:
	print(*a)


(H, W, h, w) = map(int, input().split())
A = [[0] * W for _ in range(H)]
P = 10 ** 9 - 1
M = -10 ** 9
for y in range(0, H, h):
	for x in range(0, W, w):
		A[y][x] = P
for y in range(h - 1, H, h):
	for x in range(w - 1, W, w):
		A[y][x] = M
s = sum(map(sum, A))
if s <= -1:
	print('No')
else:
	print('Yes')
	for a in A:
		print(*a)


(H, W, h, w) = map(int, input().split())
if H % h == 0 and W % w == 0:
	print('No')
else:
	print('Yes')
	k = 1000000
	R = [[0] * W for i in range(H)]
	for i in range(0, H, h):
		for j in range(0, W, w):
			R[i][j] += k
			if i + h - 1 < H:
				R[i + h - 1][j] += k
			if j + w - 1 < W:
				R[i][j + w - 1] += k
			if i + h - 1 < H and j + w - 1 < W:
				R[i + h - 1][j + w - 1] -= 3 * k + 1
	for r in R:
		print(*r)


import sys
(H, W, h, w) = map(int, input().split())
if W % w == 0 and H % h == 0:
	print('No')
	sys.exit()
print('Yes')
if W % w != 0:
	m = []
	a = str(1000 * (w - 1))
	b = str(-1001)
	for i in range(W):
		if i % w == 0:
			m.append(a)
		else:
			m.append(b)
	s = ' '.join(m)
	for i in range(H):
		print(s)
else:
	m1 = ' '.join([str(1000 * (h - 1))] * W)
	m2 = ' '.join([str(-1001)] * W)
	for i in range(H):
		if i % h == 0:
			print(m1)
		else:
			print(m2)


(H, W, h, w) = map(int, input().split())
if W % w != 0:
	print('Yes')
	s = [0 for i in range(W + 1)]
	s[W % w] = 1 + W // w
	for i in range(w, W + 1):
		s[i] = s[i - w] - 1
	a = [s[i] - s[i - 1] for i in range(1, W + 1)]
	ans = [[str(a[i]) for i in range(W)] for j in range(H)]
	for line in ans:
		print(' '.join(line))
elif H % h != 0:
	print('Yes')
	s = [0 for i in range(H + 1)]
	s[H % h] = 1 + H // h
	for i in range(h, H + 1):
		s[i] = s[i - h] - 1
	a = [s[i] - s[i - 1] for i in range(1, H + 1)]
	ans = [[str(a[i]) for j in range(W)] for i in range(H)]
	for line in ans:
		print(' '.join(line))
else:
	print('No')


(H, W, h, w) = [int(v) for v in input().split()]
if H % h == 0 and W % w == 0:
	print('No')
else:
	print('Yes')
	grid = [[-h * w * 1000 + 999 if i % h == h - 1 and j % w == w - 1 else 1000 for j in range(W)] for i in range(H)]
	for i in grid:
		print(*i)


import sys
(H, W, h, w) = map(int, input().split())
if H % h == 0 and W % w == 0:
	print('No')
elif H % h != 0:
	print('Yes')
	p = 100000 * (h - 1) - 1
	q = -100000
	L = int(H / h)
	for l in range(L):
		for i in range(W):
			print(p, end=' ')
		print('')
		for i in range(h - 1):
			for i in range(W):
				print(q, end=' ')
			print('')
	for i in range(W):
		print(p, end=' ')
	print('')
	for i in range(H - L * h - 1):
		for i in range(W):
			print(q, end=' ')
else:
	print('Yes')
	p = 100000 * (w - 1) - 1
	q = -100000
	L = int(W / w)
	s = ([p] + [q] * (w - 1)) * L + [p] + [q] * (W - L * w - 1)
	for j in range(H):
		for i in range(W):
			print(s[i], end=' ')
		print('')


(H, W, h, w) = map(int, input().split())
if H % h == 0 and W % w == 0:
	print('No')
elif h == 1:
	print('Yes')
	coef = 999999999 // (w - 1)
	(plus, minus) = (coef, -coef * (w - 1) - 1)
	for _ in range(H):
		print(*[minus if j % w == 0 else plus for j in range(1, W + 1)])
elif w == 1:
	print('Yes')
	coef = 999999999 // (h - 1)
	(plus, minus) = (coef, -coef * (h - 1) - 1)
	for i in range(1, H + 1):
		print(*[minus if i % h == 0 else plus for _ in range(W)])
else:
	print('Yes')
	coef = min(999999999 // ((h - 1) * (w - 1)), 1000000000 // (h + w - 1))
	(plus, minus) = (coef * (h + w - 1), -coef * (h - 1) * (w - 1) - 1)
	for i in range(1, H + 1):
		if i % h != 0:
			print(*[minus if j % w == 0 else plus for j in range(1, W + 1)])
		else:
			print(*[minus for _ in range(W)])


import sys
input = sys.stdin.readline
(H, W, h, w) = map(int, input().split())
if H % h == 0 and W % w == 0:
	print('No')
	exit()
(x, y) = (H // h, W // w)
s = x * y + 1
t = (h * w - 1) * s + 1
import numpy as np
grid = np.full((H + 1, W + 1), s, dtype=np.int32)
grid[::h, ::w] = -t
grid = grid[1:, 1:]
print('Yes')
for row in grid:
	print(' '.join(row.astype(str)))


(H, W, h, w) = [int(x) for x in input().split(' ')]
if W % w != 0:
	r = W % w
	n = int(W / w)
	n = n + 1
	print('Yes')
	for i in range(H):
		for k in range(W):
			if (k + 1) % w == 0:
				print(-n * (w - 1) - 1, end='')
			else:
				print(n, end='')
			if k == W - 1:
				print()
			else:
				print(end=' ')
elif H % h != 0:
	r = H % h
	n = int(H / h)
	n = n + 1
	print('Yes')
	store = 0
	for i in range(H):
		if (i + 1) % h == 0:
			store = -n * (h - 1) - 1
		else:
			store = n
		for k in range(W):
			if k == W - 1:
				print(store)
			else:
				print(store, end=' ')
else:
	print('No')


(H, W, h, w) = map(int, input().split())
if (H % h == 0) & (W % w == 0):
	print('No')
	exit()
print('Yes')
if W % w != 0:
	base = [1000] * (w - 1) + [-1000 * (w - 1) - 1]
	col = []
	for i in range(1 + W // w):
		col = col + base
	col = col[:W]
	for i in range(H):
		print(' '.join(map(str, col)))
else:
	base = [1000] * (h - 1) + [-1000 * (h - 1) - 1]
	row = []
	for i in range(1 + H // h):
		row = row + base
	row = row[:H]
	for i in row:
		col = [i] * W
		print(' '.join(map(str, col)))


min2 = lambda x, y: x if x < y else y

def solve(H, W, h, w):
	if h == 1 and w == 1:
		return None
	res = [[0] * W for _ in range(H)]
	for i in range(0, W, w):
		for j in range(0, H, h):
			res[j][i] = 10 ** 9 - 1
			if i + w - 1 < W and j + h - 1 < H:
				res[j + h - 1][i + w - 1] = -10 ** 9
	s = sum((sum(l) for l in res))
	if s <= 0:
		return None
	else:
		return res
(H, W, h, w) = map(int, input().split())
res = solve(H, W, h, w)
if res:
	print('Yes')
	print('\n'.join((' '.join(map(str, l)) for l in res)))
else:
	print('No')


(H, W, h, w) = map(int, input().split())
if h == w == 1:
	print('No')
else:
	a = (10 ** 9 - 1) // (h * w - 1)
	ret = [[a] * W for _ in range(H)]
	for y in range(h - 1, H, h):
		for x in range(w - 1, W, w):
			ret[y][x] = -a * (h * w - 1) - 1
	s = 0
	for y in range(H):
		s += sum(ret[y])
	if s > 0:
		print('Yes')
		for r in ret:
			print(*r)
	else:
		print('No')


(h, w, hh, ww) = [int(i) for i in input().split()]
area = [h * w, hh * ww]
m = h // hh * (w // ww)
a_inv = area[0] / m - area[1]
if a_inv <= 0:
	print('No')
else:
	print('Yes')
	a = a_inv ** (-1)
	if int(a) < a:
		a = int(a) + 1
	else:
		a = int(a)
	b = (area[1] - 1) * a + 1
	while b >= (area[0] / m - 1) * a:
		a += 1
		b = (area[1] - 1) * a + 1
	a = str(a)
	b = str(-b)
	for i in range(h):
		ret = [None] * w
		for j in range(w):
			if (i + 1) % hh == 0 and (j + 1) % ww == 0:
				ret[j] = b
			else:
				ret[j] = a
		print(' '.join(ret))


from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, datetime
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
mod = 10 ** 9 + 7
eps = 10 ** (-7)

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

def inpls():
	return list(input().split())
(H, W, h, w) = inpl()
MAP = [[0] * W for i in range(H)]
pl = mn = 0
tmp = 0
for y in range(H):
	for x in range(W):
		if (y + 1) % h == 0 and (x + 1) % w == 0:
			MAP[y][x] -= (h * w - 1) * 1000 + 1
			mn += 1
			tmp -= (h * w - 1) * 1000 + 1
		else:
			MAP[y][x] = 1000
			pl += 1
			tmp += 1000
if tmp <= 0:
	print('No')
else:
	print('Yes')
	for m in MAP:
		print(' '.join(map(str, m)))


def compose(W, w):
	A = [0] * W
	S = [0] * (W + 1)
	S[W % w] = 1000
	for j in range(W - w + 1):
		S[j + w] = S[j] - 1
	for j in range(W):
		A[j] = S[j + 1] - S[j]
	return A
(H, W, h, w) = map(int, input().split())
if H % h == 0 and W % w == 0:
	print('No')
else:
	print('Yes')
	if W % w:
		S = compose(W, w)
		for _ in range(H):
			print(*S)
	else:
		S = compose(H, h)
		for i in range(H):
			print(*[S[i] for _ in range(W)])


import sys

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

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

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

def read_str():
	return input()
(H, W, h, w) = read_int_list()

def solve(H, W, h, w):
	if H % h == 0 and W % w == 0:
		return (False, None)
	a = [[0] * W for _ in range(H)]
	m = 10 ** 9 - 1
	M = m + 1
	for i in range(0, H, h):
		for j in range(0, W, w):
			a[i][j] = m
	for i in range(h - 1, H, h):
		for j in range(w - 1, W, w):
			a[i][j] = -M
	return (True, a)
(possible, res) = solve(H, W, h, w)
if possible:
	print('Yes')
	for row in res:
		print(' '.join(map(str, row)))
else:
	print('No')


(H, W, h, w) = map(int, input().split())
rem = H * W - (H - H % h) * (W - W % w)
if rem == 0:
	print('No')
	exit()
x = (H // h * W // w + rem) // rem
if abs(x) > 10 ** 9 or abs(-(h * w - 1) * x - 1) > 10 ** 9:
	print('No')
	exit()
print('Yes')
a = [[x] * W for _ in range(H)]
for i in range(h - 1, H, h):
	for j in range(w - 1, W, w):
		a[i][j] = -(h * w - 1) * x - 1
for row in a:
	print(*row)


import sys
input = sys.stdin.readline

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

def solve():
	(H, W, h, w) = inpl()
	if H % h == 0 and W % w == 0:
		print('No')
		return -1
	ans = [[1000] * W for _ in range(H)]
	cnt = 0
	for i in range(h - 1, H, h):
		for j in range(w - 1, W, w):
			ans[i][j] = -(h * w - 1) * 1000 - 1
			cnt += 1
	print('Yes')
	for row in ans:
		print(' '.join(map(str, row)))
	return 0
solve()


(H, W, h, w) = map(int, input().split())
grid = [[0] * W for _ in range(H)]
inf = 10 ** 9
for i in range(H):
	for j in range(W):
		if i % h == h - 1 and j % w == w - 1:
			grid[i][j] = -inf
		elif i % h == 0 and j % w == 0:
			grid[i][j] = inf - 1
if sum([sum(line) for line in grid]) > 0:
	print('Yes')
	for i in range(H):
		print(*grid[i])
else:
	print('No')


from collections import defaultdict, deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

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

def LS():
	return [list(x) for x in sys.stdin.readline().split()]

def S():
	res = list(sys.stdin.readline())
	if res[-1] == '\n':
		return res[:-1]
	return res

def IR(n):
	return [I() for i in range(n)]

def LIR(n):
	return [LI() for i in range(n)]

def SR(n):
	return [S() for i in range(n)]

def LSR(n):
	return [LS() for i in range(n)]
sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
	(H, W, h, w) = LI()
	if W % w != 0:
		s = [0] + [100000] * (w - 1)
		for i in range(W - w + 1):
			s.append(s[-w] - 1)
		a = [s[i] - s[i - 1] for i in range(1, W + 1)]
		print('Yes')
		for i in range(H):
			print(*a)
	elif H % h != 0:
		(H, W, h, w) = (W, H, w, h)
		s = [0] + [100000] * (w - 1)
		for i in range(W - w + 1):
			s.append(s[-w] - 1)
		a = [s[i] - s[i - 1] for i in range(1, W + 1)]
		print('Yes')
		ans = [[a[i]] * H for i in range(W)]
		for i in range(W):
			print(*ans[i])
	else:
		print('No')
	return
solve()


(H, W, sh, sw) = map(int, input().split())
if H % sh == 0 and W % sw == 0:
	print('No')
else:
	print('Yes')
	state = [[1] * W for _ in range(H)]
	INF = 10 ** 9
	for h in range(H):
		for w in range(W):
			if w % sw == sw - 1 and h % sh == sh - 1:
				state[h][w] = -INF
			elif w % sw == 0 and h % sh == 0:
				state[h][w] = INF - (sh * sw - 1)
	for h in range(H):
		print(' '.join([str(a) for a in state[h]]))


(H, W, h, w) = map(int, input().split())
if W % w == 0 and H % h == 0:
	print('No')
else:
	swapped = False
	if W % w == 0:
		(H, W, h, w, swapped) = (W, H, w, h, True)
	a = [[0 for _ in range(W)] for _ in range(H)]
	for y in range(H):
		for x in range(0, W, w):
			a[y][x] = W
		for x in range(w - 1, W, w):
			a[y][x] = -W - 1
	if swapped:
		(H, W, h, w) = (W, H, w, h)
		b = a
		a = [[0 for _ in range(W)] for _ in range(H)]
		for y in range(H):
			for x in range(W):
				a[y][x] = b[x][y]
	print('Yes')
	for y in range(H):
		print(*a[y])


(H, W, h, w) = [int(i) for i in input().split()]
if H % h == 0 and W % w == 0:
	print('No')
elif W % w != 0:
	print('Yes')
	for y in range(H):
		for x in range(W):
			if x != 0:
				print(' ', end='')
			if x % w != w - 1:
				print(100000, end='')
			else:
				print(-100000 * (w - 1) - 1, end='')
		print()
else:
	print('Yes')
	for y in range(H):
		for x in range(W):
			if x != 0:
				print(' ', end='')
			if y % h != h - 1:
				print(100000, end='')
			else:
				print(-100000 * (h - 1) - 1, end='')
		print()


(H, W, h, w) = map(int, input().split())
if not (H % h or W % w):
	print('No')
	exit()
if H % h:
	flg = 'tate'
	n = H
	r = h
else:
	flg = 'yoko'
	n = W
	r = w
ans = []
if r % 2 == 0:
	s = r // 2
	for i in range(n):
		if i // s % 2 == 0:
			ans.append(2000)
		else:
			ans.append(-2001)
else:
	for i in range(n):
		if i % r < r // 2 + 1:
			ans.append(2000)
		else:
			ans.append(-int(2000 / (r // 2) * (r // 2 + 1)) - 1)
print('Yes')
if flg == 'tate':
	for i in range(H):
		print(*[ans[i]] * W)
else:
	for i in range(H):
		print(*ans)


import sys
input = sys.stdin.readline

def main():
	(H, W, h, w) = map(int, input().split())
	if H * W - H // h * (W // w) * w * h == 0:
		print('No')
	elif W % w != 0:
		ans = [0 for _ in range(W)]
		co = [0 for _ in range(W + 1)]
		for i in range(1, w):
			co[i] = (W - i) // w + 1
		for i in range(w, W + 1):
			co[i] = co[i - w] - 1
		for i in range(W):
			ans[i] = co[i + 1] - co[i]
		print('Yes')
		for i in range(H):
			print(*ans)
	else:
		ans = [0 for _ in range(H)]
		co = [0 for _ in range(H + 1)]
		for i in range(1, h):
			co[i] = (H - i) // h + 1
		for i in range(h, H + 1):
			co[i] = co[i - h] - 1
		for i in range(H):
			ans[i] = co[i + 1] - co[i]
		print('Yes')
		for i in range(H):
			print(*list((ans[i] for _ in range(W))))
main()


(H, W, h, w) = map(int, input().split())
if H % h == 0 and W % w == 0:
	print('No')
	exit(0)
blocks = H // h * (W // w)
left = H * W - blocks * h * w
offset = blocks // left + 1
v = [offset, -offset * (h * w - 1) - 1]
print('Yes')
for i in range(H):
	a = []
	for j in range(W):
		a.append(v[1 if i % h == h - 1 and j % w == w - 1 else 0])
	print(' '.join(list(map(str, a))))


(H, W, h, w) = map(int, input().split())
if H % h == 0 and W % w == 0:
	print('No')
else:
	c = 10 ** 9
	ans = [[(c - 1) // (h * w - 1) for i in range(W)] for j in range(H)]
	for i in range(H):
		for j in range(W):
			if (i + 1) % h == 0 and (j + 1) % w == 0:
				ans[i][j] = -c
	if sum((ans[i][j] for i in range(H) for j in range(W))) > 0:
		print('Yes')
		for i in range(H):
			print(*ans[i])
	else:
		print('No')


(H, W, h, w) = map(int, input().split())
a = [[0] * W for i in range(H)]
INF = 10 ** 9
for i in range(H):
	for j in range(W):
		if i % h == h - 1 and j % w == w - 1:
			a[i][j] = -INF
		elif i % h == 0 and j % w == 0:
			a[i][j] = INF - 1
if sum([sum(line) for line in a]) > 0:
	print('Yes')
	for i in range(H):
		print(*a[i])
else:
	print('No')


(H, W, a, b) = map(int, input().split())
if H % a or W % b:
	print('Yes')
	k = H // a * (W // b)
	x = k + 2
	ansss = [[0] * W for _ in range(H)]
	for i in range(H // a):
		for j in range(W // b):
			ansss[(i + 1) * a - 1][(j + 1) * b - 1] = -x
	for i in range(-(-H // a)):
		for j in range(-(-W // b)):
			ansss[i * a][j * b] = x - 1
	print('\n'.join([' '.join(map(str, anss)) for anss in ansss]))
else:
	print('No')


def get_1d(H, h):
	ret = [0] * (H + 1)
	for s in range(h):
		for (x, i) in enumerate(range(s, H, h)):
			ret[i] = -x
	for (x, i) in enumerate(range(H, 0, -h)):
		ret[i] = x + 1
	return [x1 - x0 for (x0, x1) in zip(ret, ret[1:])]

def solve(H, W, h, w):
	if H % h == 0 and W % w == 0:
		return False
	ans = []
	if H % h > 0:
		col = get_1d(H, h)
		ans.extend(([x] * W for x in col))
	else:
		row = get_1d(W, w)
		ans.extend([row] * H)
	return ans
(H, W, h, w) = map(int, input().split())
ans = solve(H, W, h, w)
if ans == False:
	print('No')
else:
	print('Yes')
	for row in ans:
		print(*row)


import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))

def main():
	(H, W, h, w) = map(int, input().split())
	if H % h == 0 and W % w == 0:
		print('No')
	elif H % h == 0:
		print('Yes')
		ans = [[0 for _ in range(W)] for _ in range(H)]
		for i in range(H):
			for j in range(0, W, w):
				ans[i][j] = 99999
				if j + w - 1 < W:
					ans[i][j + w - 1] = -100000
		for a in ans:
			print(*a)
	else:
		print('Yes')
		ans = [[0 for _ in range(W)] for _ in range(H)]
		for i in range(W):
			for j in range(0, H, h):
				ans[j][i] = 99999
				if j + h - 1 < H:
					ans[j + h - 1][i] = -100000
		for a in ans:
			print(*a)
main()


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

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

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def main():
	(H, W, h, w) = LI()
	f = False
	if H % h == 0 and W % w == 0:
		return 'No'
	if W % w == 0:
		(H, W, h, w) = (W, H, w, h)
		f = True
	p = 10 ** 6 * (w - 1) - 1
	m = -10 ** 6
	a = []
	for i in range(W):
		if i % w == 0:
			a.append(p)
		else:
			a.append(m)
	aa = [a] * H
	r = aa
	if f:
		r = [[aa[i][j] for i in range(H)] for j in range(W)]
	return 'Yes\n' + '\n'.join((' '.join(map(str, t)) for t in r))
print(main())


(h, w, h0, w0) = map(int, input().split())
if h0 == w0 == 1:
	print('No')
	exit()
(x, y) = (h // h0, w // w0)
a1cnt = h0 * w0 - 1
(a1sum, a2sum) = (h * w - x * y, x * y)
a1 = (pow(10, 9) - 1) // a1cnt
a2 = -(a1 * a1cnt + 1)
asum = a1 * a1sum + a2 * a2sum
print('Yes' if asum > 0 else 'No')
if asum > 0:
	for i in range(1, h + 1):
		a = [0] * w
		for j in range(1, w + 1):
			a[j - 1] = a2 if i % h0 == j % w0 == 0 else a1
		print(*a)


import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7

def II():
	return int(input())

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

def IAI(LINE):
	return [ILI() for __ in range(LINE)]

def IDI():
	return {key: value for (key, value) in ILI()}

def read():
	(H, W, h, w) = ILI()
	return (H, W, h, w)

def solve(H, W, h, w):
	if H % h == 0 and W % w == 0:
		return (False, None)
	else:
		matrix = [[10 ** 3] * W for __ in range(H)]
		val = -(h * w * 1000) + 999
		for _h in range(h - 1, H, h):
			for _w in range(w - 1, W, w):
				matrix[_h][_w] = val
	return (True, matrix)

def main():
	params = read()
	(ans_bool, matrix) = solve(*params)
	if ans_bool:
		print('Yes')
		for row in matrix:
			print(' '.join(map(str, row)))
	else:
		print('No')
main()


import sys

def MI():
	return map(int, sys.stdin.readline().rstrip().split())
(H, W, h, w) = MI()
(q1, r1) = (H // h, H % h)
(q2, r2) = (W // w, W % w)
if r1 == 0 and r2 == 0:
	print('No')
else:
	print('Yes')
	if r2 != 0:
		A = []
		for _ in range(q2):
			A += [2 * 10 ** 6] * (w - 1) + [-(2 * 10 ** 6) * (w - 1) - 1]
		A += [2 * 10 ** 6] * r2
		for _ in range(H):
			print(*A)
	else:
		for i in range(1, H + 1):
			if i % h != 0:
				print(*[2 * 10 ** 6] * W)
			else:
				print(*[-(2 * 10 ** 6) * (h - 1) - 1] * W)


import sys
try:
	from typing import Any, Union, List, Tuple, Dict
except ImportError:
	pass

def debug(*args):
	print(*args, file=sys.stderr)

def exit():
	sys.exit(0)
(H, W, h, w) = map(int, input().split())
(yes, no) = ('Yes', 'No')
if H % h == 0 and W % w == 0:
	print(no)
	exit()
print(yes)
unit = 1000
if W % w != 0:
	for i in range(H):
		l = []
		for j in range(W):
			if j % w == w - 1:
				l.append(str(-unit * (w - 1) - 1))
			else:
				l.append(str(unit))
		print(' '.join(l))
	exit()
if H % h != 0:
	for i in range(H):
		if i % h == h - 1:
			l = [str(-unit * (h - 1) - 1)] * W
		else:
			l = [str(unit)] * W
		print(' '.join(l))
	exit()
raise Exception('hogeeee')