Problem:
 Score : 300 points    Problem Statement We have a square grid with H rows and W columns.
Snuke wants to write 0 or 1 in each of the squares.
Here, all of the following conditions have to be satisfied:   For every row, the smaller of the following is A : the number of 0 s contained in the row, and the number of 1 s contained in the row. (If these two numbers are equal, “the smaller” should be read as “either”.)  For every column, the smaller of the following is B : the number of 0 s contained in the column, and the number of 1 s contained in the column.   Determine if these conditions can be satisfied by writing 0 or 1 in each of the squares. If the answer is yes, show one way to fill the squares so that the conditions are satisfied.      Constraints  1 \leq H,W \leq 1000  0 \leq A  2 \times A \leq W  0 \leq B  2 \times B \leq H  All values in input are integers.         Input Input is given from Standard Input in the following format:  H  W  A  B       Output If the conditions cannot be satisfied by writing 0 or 1 in each of the squares, print -1 .  If the conditions can be satisfied, print one way to fill the squares so that the conditions are satisfied, in the following format:  s_{11}s_{12}\cdots s_{1W}  s_{21}s_{22}\cdots s_{2W}  \vdots  s_{H1}s_{H2}\cdots s_{HW}   Here s_{ij} is the digit written in the square at the i -th row from the top and the j -th column from the left in the grid.  If multiple solutions exist, printing any of them will be accepted.        Sample Input 1 3 3 1 1      Sample Output 1 100
010
001  Every row contains two 0 s and one 1 , so the first condition is satisfied.
Also, every column contains two 0 s and one 1 , so the second condition is satisfied.       Sample Input 2 1 5 2 0      Sample Output 2 01010

Solution (Python):
def main():
    h,w,a,b=map(int,input().split())
    Ans=[[0]*w for _ in range(h)]
    for x in range(h):
        for y in range(w):
            Ans[x][y]=int((x<b)^(y<a))
    for ans in Ans:
        print(*ans,sep='')
    return
    
if __name__=='__main__':
    main()

Solution (Python):
H, W, A, B = map(int, input().split())

if A == 0 and B == 0:
    for i in range(H):
        ans = ["1"] * W
        print("".join(ans))
elif A == 0:
    for i in range(B):
        ans=[]
        temp = ["1"] * W
        ans.extend(temp)
        print("".join(ans))
    for i in range(H - B):
        ans=[]
        temp = ["0"] * W
        ans.extend(temp)
        print("".join(ans))
elif B == 0:
    for i in range(H):
        ans1=[]
        ans1 = ["1"] * A
        ans2 = ["0"] * (W - A)
        ans1.extend(ans2)
        print("".join(ans1))
else:
    for i in range(B):
        ans1 = ["1"]*A
        ans2=["0"]*(W-A)
        ans1.extend(ans2)
        print("".join(ans1))
    for i in range(H-B):
        ans1=["0"]*A
        ans2=["1"]*(W-A)
        ans1.extend(ans2)
        print("".join(ans1))

Solution (Python):
import sys
input=sys.stdin.readline

def main():
    H,W,A,B = map(int,input().split())
    for h in range(H):
        if h < B:
            print("0"*A+"1"*(W-A))
        else:
            print("1"*A+"0"*(W-A))

if __name__ == '__main__':
    main()

Solution (Python):
H, W, A, B = map(int, input().split())

for i in range(B):
  print('0'*A+'1'*(W-A))
for i in range(H-B):
  print('1'*A+'0'*(W-A))

Solution (Python):
h, w, a, b = map(int, input().split())

for _ in range(b):
  print(''.join(['0'] * a + ['1'] * (w-a)))
for _ in range(h-b):
  print(''.join(['1'] * a + ['0'] * (w-a)))

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    H, W, A, B = map(int, input().split())

    ans = []
    for h in range(B):
        row = [0]*A + [1]*(W-A)
        ans.append(row)
    
    for h in range(H-B):
        row = [1]*A + [0]*(W-A)
        ans.append(row)
    
    for a in ans:
        print(''.join(map(str, a)))

if __name__ == '__main__':
    main()

Solution (Python):
h,w,a,b=map(int,input().split())
for i in range(b):
  print(*([0]*a+[1]*(w-a)),sep="")
for i in range(h-b):
  print(*([1]*a+[0]*(w-a)),sep="")

Solution (Python):
h,w,a,b=map(int,input().split());print("\n".join(["1"*a+"0"*(w-a)]*b+["0"*a+"1"*(w-a)]*(h-b)))

Solution (Python):
def main():
    h,w,a,b=map(int,input().split())
    Ans=[[0]*w for _ in range(h)]
    for x in range(h):
        for y in range(w):
            Ans[x][y]=int((x<b)^(y<a))
    for ans in Ans:
        print(*ans,sep='')
    return
    
if __name__=='__main__':
    main()

Solution (Python):
H, W, A, B = map(int, open(0).read().split())

S = [["1"] * W for _ in range(H)]

for i in range(H):
    for j in range(W):
        if (i < B and j < A) or (i >= B and j >= A):
            S[i][j] = "0"

print("\n".join("".join(s) for s in S))

Solution (Python):
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        for _ in range(num): return []
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(map(int, input().split())) for _ in range(N)]
        return map(list,zip(*read_all))



H,W,A,B = II()

s = [['0']*W for _ in range(H)]

for i in range(B):
    for j in range(A):
        s[i][j] = '0'
    for j in range(A,W):
        s[i][j] = '1'

for i in range(B,H):
    for j in range(A):
        s[i][j] = '1'
    for j in range(A,W):
        s[i][j] = '0'

for i in range(H):
    print(''.join(s[i]))

Solution (Python):
import sys

H,W,A,B=map(int,input().split())
mat=[]
for _ in range(H):
  array=[0]*W
  mat.append(array)
  
for i in range(B):
  for j in range(A):
    mat[i][j]=1
for i in range(B,H):
  for j in range(A,W):
    mat[i][j]=1
  

for i in range(H):  
  print("".join(map(str,mat[i])))

Solution (Python):


h, w, a, b = map(int, input().split())

s = [[0] * a + [1] * (w - a), [1] * a + [0] * (w - a)]
for i in range(b):
    for ele in s[0]:
        print(ele, end="")
    print()

for i in range(h - b):
    for ele in s[1]:
        print(ele, end="")
    print()

Solution (Python):
H, W, A, B = map(int, input().split())
for i in range(H):
    if i < B:
        temp = '0' * A + '1' * (W - A)
    else:
        temp = '1' * A + '0' * (W - A)
    print(temp)

Solution (Python):
h,w,a,b=map(int,input().split());print("\n".join(["1"*a+"0"*(w-a)]*b+["0"*a+"1"*(w-a)]*(h-b)))

Solution (Python):
h, w, a, b = map(int, input().split())

for i in range(h):
    if i < h - b:
        print("0" * a + "1" * (w-a))
    else:
        print("1" * a + "0" * (w-a))

Solution (Python):
def ng():
    print("No")
    exit(0)


H, W, A, B = map(int, input().split())

vT = [0,] * W
mR = []

if (A, B) == (0, 0):
    for h in range(H):
        mR.append(["0",] * W)

elif A == 0:
    for b in range(B):
        mR.append(["1",] * W)
    for h in range(H - B):
        mR.append(["0",] * W)

elif B == 0:
    for h in range(H):
        vR = ["1",] * A + ["0",] * (W-A)
        mR.append(vR)

else:
    for b in range(B):
        vR = ["1",] * A + ["0",] * (W-A)
        mR.append(vR)
    for h in range(H - B):
        vR = ["0",] * A + ["1",] * (W-A)
        mR.append(vR)
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    

    

    
    

for v in mR:
    print("".join(v))

Solution (Python):
H, W, A, B = list(map(int, input().split()))

if H == 1 and W == 1:
    print(0)
else:
    if A <= (W // 2) and B <= (H // 2):
        for i in range(H):
            b = ''
            if i < H - B:
                for j in range(W):
                    if j < A:
                        b += '1'
                    else:
                        b += '0'
            else:
                for j in range(W):
                    if j < A:
                        b += '0'
                    else:
                        b += '1'
            print(b)
    else:
        print('No')

Solution (Python):
h, w, a, b = map(int, input().split())
li1 = str(1)*a+str(0)*(w-a)
li2 = str(0)*a+str(1)*(w-a)
for _ in range(h-b):
    print(li1)
for _ in range(b):
    print(li2)

Solution (Python):



def solve(arg: str) -> str:
    h, w, a, b = map(int, arg.split())
    mat = [[0] * w for _ in range(h)]
    sumy = [0] * w

    for y in range(h):
        sumx = 0
        for x in range(w):
            if(
                (sumy[x] < b and sumx < a) or
                (sumy[x] < h - b and sumx < a) or
                (sumy[x] < b and sumx < w - a) or
                (sumy[x] < h - b and sumx < w - a)
            ):
                mat[y][x] = 1
                sumx += 1
                sumy[x] += 1
        if(min(sumx, w - sumx) != a):
            return 'No'

    for s in sumy:
        if(min(s, h - s) != b):
            return 'No'

    ret = ''
    for y in range(h):
        for x in range(w):
            ret += str(mat[y][x])
        if(y != h-1):
            ret += '\n'

    return ret


if __name__ == "__main__":
    print(solve(input()))

Solution (Python):

import sys
def input():
	return sys.stdin.readline().strip()

H, W, A, B = list(map(int, input().split()))

ans = []

for i in range(H):
	if i < 2*B:
		if i % 2 == 0:
			x = [1]*A
			x.extend([0]*(W - A))
		else:
			x = [0]*A
			x.extend([1]*(W - A))
	else:
		x = [1] * A
		x.extend([0] * (W - A))
	ans.append(x)

for i in range(H):
	for j in range(W):
		ans[i][j] = str(ans[i][j])


for i in range(H):
	print("".join(ans[i]))

Solution (Python):
h,w,a,b=map(int,input().split())
x="1"*a+"0"*(w-a);y="0"*a+"1"*(w-a)
print("\n".join([x]*b+[y]*(h-b)))

Solution (Python):
import sys
h, w, a, b = map(int, input().split())
x, y = -1, -1
for i in range(h+1):
    for j in range(w+1):
        if a*i + (w-a)*(h-i) == b*j + (h-b)*(w-j):
            x, y = i, j
            break
    if not(x == y == -1): break
if x == y == -1:
    print("No")
    sys.exit()
numh = [0]*h
numw = [0]*w
for i in range(h):
    for j in range(w):
        if j < y:
            if numw[j] < b and ((i < x and numh[i] < a) or (i >= x and numh[i] < w-a)):
                print("0", end="")
                numh[i] += 1
                numw[j] += 1
            else: print("1", end="")
        else:
            if numw[j] < h-b and ((i < x and numh[i] < a) or (i >= x and numh[i] < w-a)):
                print("0", end="")
                numh[i] += 1
                numw[j] += 1
            else: print("1", end="")
    print("")

Solution (Python):
H, W, A, B = map(int, input().split())

S01 = '0'*A + '1'*(W-A)
S10 = '1'*A + '0'*(W-A)
for i in range(H):
  if i < B:
    print(S01)
  else:
    print(S10)

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
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)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


h, w, a, b = LI()
L1 = [0] * (h + 1)
for i in range(h + 1):
    L1[i] = a * i + (w - a) * (h - i)


L2 = [0] * (w + 1)
for j in range(w + 1):
    L2[j] = b * j + (h - b) * (w - j)


flag = 0
for k in range(h + 1):
    for l in range(w + 1):
        if L1[k] == L2[l]:
            flag = 1
            break
    if flag:
        break


if flag:
    tate = [a] * k + [w - a] * (h - k)
    yoko = [b] * l + [h - b] * (w - l)
    ans = [[0] * w for _ in range(h)]
    for y in range(h):
        for x in range(w):
            if tate[y] and yoko[x]:
                ans[y][x] = 1
                tate[y] -= 1
                yoko[x] -= 1
    for i in range(h):
        print(*ans[i], sep='')
else:
    print('No')

Solution (Python):


def main():
    H, W, A, B = map(int, input().split())

    s0 = '1'*A + '0'*(W-A);
    s1 = '0'*A + '1'*(W-A);

    for _ in range(B):
        print(s0)

    for _ in range(H-B):
        print(s1)


if __name__ == '__main__':
    main()

Solution (Python):
h,w,a,b = map(int,input().split())
p = -1
q = -1
for i in range(h+1):
    if p != -1:
        break
    for j in range(w+1):
        if i*a + (h-i)*(w-a) == j*b + (w-j)*(h-b):
            p = i
            q = j
            break

Row = [w-a]*(h-p)+[a]*p
Column = [h-b]*(w-q)+[b]*q

Ans = [[0 for i in range(w)] for j in range(h)]

for i in range(h):
    for j in range(w):
        if Column[j] != 0 and Row[i] != 0:
            Column[j] -= 1
            Row[i] -= 1
            Ans[i][j] = 1
        elif Row[i] == 0:
            break
        elif Column[j] == 0:
            continue
if p == -1:
    print('No')
else:
    for ans in Ans:
        print(''.join(map(str,ans)))

Solution (Python):
h,w,a,b = map(int,input().split())

if (2*b > h) or (2*a > w):
  print('No')

elif (a==0 and b==0):
  for hi in range(h):
    print('0'*w)    
    
elif a==0:
  for hi in range(h):
    if hi < b:
      print('1'*w)
    else:
      print('0'*w)

elif b==0:
  s = '1'*a + '0'*(w-a)
  for hi in range(h):
    print(s)  
    
else:
  s = '1'*a + '0'*(w-a)
  rs = ''.join(['0' if i=='1' else '1' for i in s])
  for hi in range(h):
    if hi < b:
      print(s)
    else:
      print(rs)

Solution (Python):
import sys

H,W,A,B = map(int,input().split())

if H//2 < B or W//2 < A:
    print("No")
    sys.exit()

ans1 = ''
ans2 = ''
for i in range(W):
    if i < A:
        ans1 = ans1 + '1'
        ans2 = ans2 + '0'
    else:
        ans1 = ans1 + '0'
        ans2 = ans2 + '1'

for _ in range(B):print(ans1)
for _ in range(H-B):print(ans2)

Solution (Python):
H,W,A,B=map(int,input().split())
X=[[0 for j in range(W)] for i in range(H)]
for i in range(H):
    for j in range(W):
        if i<2*B and j<2*A:
            X[i][j]=(i+j)%2
        elif i<B or j<A:
            X[i][j]=0
        else:
            X[i][j]=1

for line in X:
    print("".join([str(i) for i in line]))

Solution (Python):
import numpy as np
H,W,A,B=np.array(list(map(int, input().split())))

for row in range(H):
    if  row<=B-1:
        print(''.join(list(map(str, [1 if i<=A-1 else 0 for i in range(W)]))))
    else:
        print(''.join(list(map(str, [0 if i<=A-1 else 1 for i in range(W)]))))

Solution (Python):
h,w,a,b = map(int, input().split())


up = []
if a>0:
  for i in range(a):
    up.append(1)
for i in range(w-a):
  up.append(0)

down = [1-up[i] for i in range(w)]

str_up = [str(i) for i in up]
str_down = [str(i) for i in down]

ans_up = ''.join(str_up)
ans_down = ''.join(str_down)

if b>0:
  for i in range(b):
    print(ans_up)
for i in range(h-b):
  print(ans_down)

Solution (Python):
H, W, A, B = map(int, input().split())
matr = [[0 for _ in range(W)] for _ in range(H)]

for h in range(H):
  for w in range(W):
    if w >= A and h >= B:
      matr[h][w] = 1
    if w < A and h < B:
      matr[h][w] = 1
    

for h in range(H):
  for w in range(W):
    print(matr[h][w], end = '')
  print()

Solution (Python):
a=[]
for x in input().split(" "):
    a.append(int(x))

i=0
j=0
b=[]
bn=[]
bb=[]
bc=[]

while i < a[0] - a[3]:
    bb = ["0"] * (a[1] - a[2])
    bc = ["1"] * a[2]
    bn = bb + bc
    b.append(bn)
    i += 1
    bb = []
    bc = []
while i < a[0]:
    bb = ["1"] * (a[1] - a[2])
    bc = ["0"] * a[2]
    bn = bb + bc
    b.append(bn)
    i += 1
    bb = []
    bc = []

for x in b:
    print(''.join(x))

Solution (Python):
H,W,A,B=map(int,input().split())


h=[A*H+i*(W-2*A) for i in range(H)]
w=[B*W+i*(H-2*B) for i in range(W)]




for i,hh in enumerate(h):
  if hh in w:
    

    aa=[]
    for a in range(H-i):
      aa.append(W-A)
    for a in range(i):
      aa.append(A)
    

    bb=[]
    for b in range(W-w.index(hh)):
      bb.append(H-B)
    for b in range(w.index(hh)):
      bb.append(B)
    
    
    for a in range(H):
      pp=""
      for b in range(W):
        
        if aa[a]>0 and bb[b]>0:
          pp+="1"
          aa[a]-=1
          bb[b]-=1
        else:
          pp+="0"
      print(pp)
    exit()

print("No")

Solution (Python):
import numpy as np
H,W,A,B=map(int,input().split())
P=np.concatenate([np.ones((H-B,W-A)),np.zeros((B,W-A))])
Q=np.concatenate([np.zeros((H-B,A)),np.ones((B,A))])
ans = np.concatenate([P,Q],1)
for j in ans:
    print(''.join(map(str,map(int,j))))

Solution (Python):
d = input().split(' ')
w = int(d[0])
h = int(d[1])
a = int(d[2])
b = int(d[3])

s1 = ''
s2 = ''
for j in range(h):
  if j < a:
    s1 = s1 + '1'
    s2 = s2 + '0'
  else:
    s1 = s1 + '0'
    s2 = s2 + '1'

k = []
for i in range(w):
  if i < b:
    print(s1)
  else:
    print(s2)

Solution (Python):
h, w, a, b = map(int, input().split())

l1 = "1"*a + "0"*(w-a)
l2 = "0"*a + "1"*(w-a)
ans = "\n".join([l1] * b + [l2] * (h-b))
print(ans)

Solution (Python):
h, w, a, b = [int(v) for v in input().split()]

l1 = [0] * w
l2 = [0] * w
for i in range(w):
  if i < a:
    l1[i] = "1"
    l2[i] = "0"
  else:
    l1[i] = "0"
    l2[i] = "1"

for j in range(h):
  if j < b:
    print("".join(l1))
  else:
    print("".join(l2))

Solution (Python):
def main():
    h, w, a, b = list(map(int, input().split()))
    result_list = []
    for _ in range(b):
        result_list.append([0] * a + [1] * (w-a))
        if not min_count(result_list[-1]) == a:
            print('No')
            exit()
    for _ in range(h-b):
        result_list.append([1] * a + [0] * (w-a))
        if not min_count(result_list[-1]) == a:
            print('No')
            exit()
    for i in range(w):
        temp_list = []
        for j in range(h):
            temp_list.append(result_list[j][i])
        if not min_count(temp_list) == b:
            print('No')
            exit()
    result_str = ''
    for content in result_list:
        result_str += str(''.join(list(map(str, content)))) + '\n'
    print(result_str)


def min_count(input_list):
    zero = 0
    one = 0
    for v in input_list:
        if v == 0:
            zero += 1
        else:
            one += 1
    return min(zero, one)


if __name__ == '__main__':
    main()

Solution (Python):
h, w, a, b = map(int, input().split())
for _ in range(h - b):
  print('1' * a + '0' * (w - a))
for _ in range(b):
  print('0' * a + '1' * (w - a))

Solution (Python):
import heapq

h, w, a, b = map(int, input().split())

right = a*h - b*w
ex = 2*a - w
ey = 2*b - h
x = 0
y = 0
error = True
for i in range(h+1):
    for j in range(w+1):
        if ex * i - ey * j == right:
            x = i
            y = j
            error = False
            break

if error == True:
    exit()
lp = []
for i in range(w-y):
    heapq.heappush(lp, (b-h, i))
for i in range(w-y, w):
    heapq.heappush(lp, (-b, i))
lit = [[0] * w for _ in range(h)]

for i in range(h):
    point = a
    if i < h - x:
        point = w-a
    popped = []
    for j in range(point):
        score, jx = heapq.heappop(lp)
        lit[i][jx] = 1
        if score+1 < 0:
            popped.append((score+1, jx))
    for score, jx in popped:
        heapq.heappush(lp, (score, jx))
    print(''.join(map(str, lit[i])))

Solution (Python):
h,w,a,b=[int(i) for i in input().split()]
ans=[[0]*w for _ in range(h)]

def printf(array):
    for v in array:
        print(*v, sep="")
    quit()

for i in range(h):
    for j in range(w):
        if (i<b and j<a) or (i>=b and j>=a):
            ans[i][j]=1

printf(ans)

Solution (Python):
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

H, W, A, B = MAP()
M = [[0] * W for _ in range(H)]
for hh in range(H):
    for ww in range(W):
        if ww < A and hh < B:
            M[hh][ww] = 1
        if ww >= A and hh >= B:
            M[hh][ww] = 1
for hh in range(H):
    print("".join([str(n) for n in M[hh]]))

Solution (Python):
h,w,a,b = map(int,input().split())
s = [['0']*w for _ in range(h)]

for i in range(b):
    for j in range(a):
        s[i][j] = '1'

for i in range(h-b):
    for j in range(w-a):
        s[i+b][j+a] = '1'

for i in range(h):
    print(''.join(s[i]))

Solution (Python):
h,w,a,b=map(int,input().split(' '))

for i in range(h):
  ans = ""
  for j in range(w):
    if j < a:
      if i < b:
        ans = ans + "1"
      else:
        ans = ans + "0"
    else:
      if i < b:
        ans = ans + "0"
      else:
        ans = ans + "1"
  print(ans)

Solution (Python):
tmp = list(map(int,(input().split())))
h = tmp[0]
w = tmp[1]
a = tmp[2]
b = tmp[3]

for i in range(h):
  if b > i:
    vld = 1
    inv = 0
  else:
    vld = 0
    inv = 1
  for j in range(w):
    if a > j:
      print(vld, end="")
    else:
      print(inv, end="")
  print('')

Solution (Python):
import numpy as np

H, W, A, B = list(map(int, input().split()))

C = np.zeros([H, W])

C[0:H-B, 0:W-A] = 1
C[H-B:H, W-A:W] = 1

for i in range(H):
    d = ""
    for j in range(W):
        d += str(int(C[i, j]))

    print(d)

Solution (Python):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from heapq import heappush, heappop

def find_rc(h, w, a, b):
    row = -1
    col = -1

    for r in range(h+1):
        for c in range(w+1):
            if (2*a - w) * r - a * h == (2*b - h) * c - b * w:
                return r, c

    return row, col

def construct(h, w, a, b, r, c):
    grid = [[""]*w for _ in range(h)]

    heap = []
    for col in range(w):
        if col < c:
            heappush(heap, (-b, col))
        else:
            heappush(heap, (-(h-b), col))

    for row in range(h):
        if row < r:
            for _ in range(a):
                rest, col = heappop(heap)
                grid[row][col] = "0"
                heappush(heap, (rest + 1, col))
        else:
            for _ in range(w - a):
                rest, col = heappop(heap)
                grid[row][col] = "0"
                heappush(heap, (rest + 1, col))

    for rr in range(h):
        for cc in range(w):
            if grid[rr][cc] == "":
                grid[rr][cc] = "1"

    for row in grid:
        print("".join(row))

h, w, a, b = li()


r, c = find_rc(h, w, a, b)
if r == -1:
    print("No")
else:
    construct(h, w, a, b, r, c)

Solution (Python):
H, W, A, B = map(int, input().split())

line_s = '0' * A + '1' * (W - A)
opps_s = '1' * A + '0' * (W - A)

for _ in range(B):
    print(line_s)

for _ in range(H - B):
    print(opps_s)

Solution (Python):
h,w,a,b=map(int,input().split())
for _ in [0]*b:
    print('0'*a+'1'*(w-a))
for _ in [0]*(h-b):
    print('1'*a+'0'*(w-a))

Solution (Python):
h, w, a, b = map(int, input().split())

ans = []
for i in range(b):
    l = [1 for j in range(w)]
    ans.append(l)

for i in range(h-b):
    l = [0 for j in range(w)]
    ans.append(l)

if h % 2 == 0:
    m = int(h/2)
else:
    m = int(h/2) + 1

for i in range(m):
    if sum(ans[2*i]) != a or sum(ans[2*i]) != w-a:
        for j in range(min(abs(sum(ans[2*i])-a), abs(sum(ans[2*i])-w+a))):
            ans[2*i][j] = 1 - ans[2*i][j]
            if i != int(h/2):
                ans[2*i+1][j] = 1 - ans[2*i+1][j]
                
for i in range(len(ans)):
    for j in range(len(ans[i])):
        print(ans[i][j], end="")
    print()

Solution (Python):
h,w,a,b = map(int, input().split())
if h == 1:
    S = "1"*a+"0"*(w-a)
    print(S)
elif w == 1:
    S = [1]*b+[0]*(h-b)
    for s in S:
        print(s)
elif h >= 2 and w >= 2:
    
    
    
    
    for i in range(h):
        
        if i < b:
            S = "1"*a + "0"*(w-a)
        else:
            S = "0"*a + "1"*(w-a)
        print(S)

Solution (Python):
import sys
input = sys.stdin.readline

H,W,A,B=map(int,input().split())

ANS=[]
for i in range(B):
    ANS.append([0]*A+[1]*(W-A))

for i in range(H-B):
    ANS.append([1]*A+[0]*(W-A))

for ans in ANS:
    print("".join(map(str,ans)))

Solution (Python):
h,w,a,b = map(int,input().split())
ans1 = [0]*a + [1]*(w-a)
ans2 = [1]*a + [0]*(w-a)
ans = []
for i in range(h):
    if i <= b-1:
        ans.append(ans1)
    else:
        ans.append(ans2)

for i in range(h):
    for j in range(w):
        print(ans[i][j],end='')
    print()

Solution (Python):
h, w, a, b = map(int, input().split())

s = [[0 for _ in range(w)] for _ in range(h)]

num = [0, 1]
flag = True
for i in range(h):
    for j in range(w):
        if b <= i and flag:
            num.reverse()
            flag = False
        if j < a:
            s[i][j] = num[0]
        else:
            s[i][j] = num[1]


for row in s:
    tmp = list(map(str, row))
    print("".join(tmp))

Solution (Python):
from sys import stdin
H, W, A, B = [int(x) for x in stdin.readline().rstrip().split()]
if (W >= (2*A+1)) and (H >= (2*B+1)):
    for i in range(B):
        print(A*"0"+"1"*(W-A))
    for j in range(H-B):
        print(A*"1"+"0"*(W-A))
    
else:
    print("No")

Solution (Python):

h,w,a,b=map(int, input().split())

point = w - a
hanten = h -b
for i in range(h):
        for j in range (w):
            if (i < hanten):
                if (j < point):
                    print("0", end="")
                else:
                    print("1", end="")
            else:
                if (j < point):
                    print("1", end="")
                else:
                    print("0", end="")

        print("")

Solution (Python):
import sys
input = sys.stdin.readline

def main():
    H, W, A, B = map(int, input().split())

    if A * 2 > W or B * 2 > H:
        print("No")
        return
    
    for i in range(H-B):
        for j in range(W-A):
            print(1, end="")
        for j in range(A):
            print(0, end="")
        print()
    for i in range(B):
        for j in range(W-A):
            print(0, end="")
        for j in range(A):
            print(1, end="")
        print()


if __name__ == "__main__":
    main()

Solution (Python):
def solve():
    H,W,A,B = map(int, input().split())
    matrix = [[0 for j in range(W)] for i in range(H)]
    for i in range(H):
        for j in range(W):
            if i <= B-1:
                if j <= A-1:
                    print(1,end="")
                else:
                    print(0,end="")
            else:
                if j <= A-1:
                    print(0,end="")
                else:
                    print(1,end="")
        print("")
solve()

Solution (Python):
import sys; from collections import deque; readline = sys.stdin.readline

H, W, A, B = map(int, readline().split())













for y in range(B):
    print(''.join(map(str, [1]*A + [0]*(W-A))))

for y in range(B, H):
    print(''.join(map(str, [0]*A + [1]*(W-A))))

Solution (Python):
height, length, A, B = [int(s) for s in input().split()]
matrix = [[0 for t in range(length)] for s in range(height)]

for k,i in enumerate(matrix):
  if k + 1 <= B:
    for j in range(A):
      i[j] = 1
  else:
    for j in range(length - A):
      i[-(j + 1)] = 1
      
for i in matrix:
  p = ""
  for j in i:
    p += str(j)
  print(p)

Solution (Python):
from sys import stdin

H, W, A, B = [int(x) for x in stdin.readline().rstrip().split()]

ans_top = [[1] * (W - A) + [0] * A for _ in range(H - B)]
ans_bottom = [[0] * (W - A) + [1] * A for _ in range(B)]
ans = ans_top + ans_bottom
for a in ans:
    print(*a, sep="")

Solution (Python):
H, W, A, B = map(int, input().split())
ans = []
for i in range(B):
  ans.append("1"*A+"0"*(W-A))
for j in range(H-B):
  ans.append("0"*A+"1"*(W-A))
for k in ans:
  print(k)

Solution (Python):
H,W,A,B = map(int, input().split())

W1 = '1' * A + '0' * (W - A)
W0 = '0' * A + '1' * (W - A)

if A > (W // 2) or B > (H // 2):
    print('No')
    exit()

if H == 1:
    print(W1)
    exit()
elif W == 1:
    for _ in range(B):
        print('1')
    for _ in range(H - B):
        print('0')
    exit()


ans = []
ans.append(W1)

for _ in range(B):
    ans.append(W0)

for _ in range(H - B - 1):
    ans.append(W1)

for i in ans:
    print(i)

Solution (Python):
H, W, A, B = map(int, input().split())
ans = [['0' for i in range(W)] for j in range(H)]

for i in range(H):
    for j in range(W):
        if j+1 <= A and i+1 <= B:
            ans[i][j] = '1'
        elif j+1 > A and i+1 > B:
            ans[i][j] = '1'
        
for i in range(H):
    print(''.join(ans[i]))

Solution (Python):
H,W,A,B=map(int,input().split())
for b in range(B):
    print('0'*A+'1'*(W-A))
for b in range(H-B):
    print('1'*A+'0'*(W-A))

Solution (Python):
h,w,a,b = map(int,input().split())

line = []
inv_line = []

for i in range(w):
    if i <= a-1:
        line.append(0)
        inv_line.append(1)
    else:
        line.append(1)
        inv_line.append(0)


for i in range(h):
    if i >= b:
        for j in range(w):
            print(line[j],end="")
        print('')
    else:
        for j in range(w):
            print(inv_line[j],end="")
        print('')

Solution (Python):
H, W, A, B = map(int, input().split())

mat = [[0] * W for _ in range(H)]


for i in range(B):
    for j in range(A):
        mat[i][j] = 1


for i in range(B, H):
    for j in range(A, W):
        mat[i][j] = 1

for line in mat:
    print("".join(map(str, line)))

Solution (Python):
H,W,A,B = map(int,input().split())

for i in range(B):
    print('1'*A + '0'*(W-A))
for i in range(H-B):
    print('0'*A + '1'*(W-A))

Solution (Python):
H,W,A,B=map(int,input().split())
flag=0
T=[]
C=[]
if True:
    for i in range(A):
        T.append("1")
        C.append("0")
    for i in range(W-A):
        T.append("0")
        C.append("1")
    for i in range(B):
        print("".join(T))
    for i in range(H-B):
        print("".join(C))

else:
    print("No")

Solution (Python):
H,W,A,B = map(int, input().split())
s1 =''
s2 =''
str1 = '0'
str2 = '1'
for i in range(0,A):
  s1 += str1
  s2 += str2

for j in range(A,W):
  s1 += str2
  s2 += str1

for p in range(0,B):
  print(s1)

for p in range(B,H):
  print(s2)

Solution (Python):
H, W, A, B = map(int, input().split())

ans = [[0 for _ in range(W)] for _ in range(H)]

for i in range(H):
  for j in range(A):
    ans[i][j] = 1

for i in range(B):
  for j in range(W):
    ans[i][j] ^= 1

for i in range(H):
  for j in range(W):
    print(ans[i][j], end = "")
  print()

Solution (Python):

h,w,a,b=list(map(int,input().split()))

ans=""

for i in range(1,h+1):
    if i<=b:
        s="1"*a+"0"*(w-a)
    else:
        s="0"*a+"1"*(w-a)
    ans+=s+"\n"
print(ans)

Solution (Python):


import sys



tmp = input().split()
h,w,a,b = list(map(lambda a: int(a), tmp))



for i in range(h):
	outh=""
	if(i<b):
		for j in range(w):
			if(j<a):
				outh+="1"
			else:
				outh+="0"


		print(outh)
	else:
		for j in range(w):
			if(j<a):
				outh+="0"
			else:
				outh+="1"


		print(outh)