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 print_ans():
    for i in field:
        print("".join(i))
    exit()
        
h,w,a,b=map(int,input().split())

field=[["0"]*w for i in range(h)]

if a==0:
    if b==0:
        print_ans()
    else:
        for i in range(b):
            field[i]=["1"]*w
        print_ans()
if b==0:
    for i in range(h):
        for j in range(a):
            field[i][j]="1"
    print_ans()
    
for i in range(h):
    for j in range(w):
        if i<b and j<a:
            field[i][j]="1"
        if i>=b and j>=a:
            field[i][j]="1"
print_ans()

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

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

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

C = [1]*(W-A) + [0]*A
D = [0]*(W-A) + [1]*A
c = ''
d = ''
for i in C:
    c += str(i)
c = int(c)
for i in D:
    d += str(i)
d = d.zfill(W)

for i in range(H):
    if i < H-B:
        print(c)
    else:
        print(d)

Solution (Python):
h, w, a, b = map(int, input().split())
s = [[0] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if (i < b and j < a) or (b <= i and a <= j):
            s[i][j] = 1
for t in s:
    print("".join(map(str, t)))

Solution (Python):
import sys
import math  
import bisect  
import queue  


def input():
    return sys.stdin.readline().rstrip()


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

    res = []
    for _ in range(B):
        row = [0 for _ in range(W)]
        for i in range(A, W):
            row[i] = 1
        res.append(row)

    for _ in range(H - B):
        row = [0 for _ in range(W)]
        for i in range(A):
            row[i] = 1
        res.append(row)

    for re in res:
        re = [str(r) for r in re]
        print(''.join(re))


if __name__ == '__main__':
    main()

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

map = []
for i in range(H):
    line = []
    for j in range(W):
        if i < B and j < A or B <= i and A <= j:
            line.append('1')
        else:
            line.append('0')
    map.append(line)

print('\n'.join([''.join(m) for m in map]))

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

for i in range(a):
    for j in range(b):
        ans[j][i] = 1
        
for i in range(w-a):
    for j in range(h-b):
        ans[b+j][a+i] = 1
        
for i in range(h):
    print(*ans[i],sep = "")

Solution (Python):
H, W, A, B = map(int, input().split())
ans = [0]*H
for i in range(H):
  if i < B:
    ans[i] = "0"*A + "1"*(W-A)
  else:
    ans[i] = "1"*A + "0"*(W-A)
print(*ans, sep="\n")

Solution (Python):
h,w,a,b = map(int, input().split())
ans=[]
for i in range(h):
    if i<b:
        ans.append([0]*w)
    else:
        ans.append([1]*w)
for i in range(h):
    for j in range(w):
        if j<a:
            ans[i][j] = (ans[i][j] + 1)%2
for a in ans:
    print(*a,sep="")

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

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

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

for i in range(H):
    for j in range(W):
        if j<A and i<B:
            s[i][j]=0
        elif j<A:
            s[i][j]=1
        elif i<B:
            s[i][j]=1
        else:
            s[i][j]=0
ans=[]
for i in range(H):
    tmp=""
    for j in range(W):
        tmp=tmp+str(s[i][j])
    ans.append(tmp)
for i in range(H):
    print(ans[i])

Solution (Python):
h,w,a,b=map(int,input().split());x='01'
for i in range(h):print(x[i<b]*a+x[i>=b]*(w-a))

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

for _ in range(b):
  print("0" * a + "1" * (w - a))
for _ in range(b, h):
  print("1" * a + "0" * (w - a))

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

for i in range(H):
    z, o = ('0', '1') if i < B else ('1', '0')
    print(''.join([z] * A + [o] * (W - A)))

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

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

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())
ans = [[0]*w for _ in range(h)]

for i in range(h-b):
    for j in range(a):
        ans[i][j] = 1

for i in range(h-b, h):
    for j in range(a, w):
        ans[i][j] = 1

for row in ans:
    print(*row, sep='')

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    H, W, A, B = map(int, rl().split())
    s = [[0] * W for _ in range(H)]
    for i in range(B):
        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 si in s:
        print(''.join(map(str, si)))


if __name__ == '__main__':
    solve()

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

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

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

for i in l:
    print("".join(map(str, i)))

Solution (Python):
h,w,a,b=map(int,input().split())
ans=[['0']*w for _ in range(h)]
if a==0:
  for i in range(b):
    for j in range(w):
      ans[i][j]='1'
elif b==0:
  for i in range(h):
    for j in range(a):
      ans[i][j]='1'
else:
  for i in range(b):
    for j in range(a):
      ans[i][j]='1'
  for i in range(b,h):
    for j in range(a,w):
      ans[i][j]='1'
for i in range(h):
  print(''.join(ans[i]))

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

Solution (Python):
import math


input = str(input()).split(" ")
for index in range(len(input)):
    input[index] = int(input[index])
h, w, a, b = input[0], input[1], input[2], input[3]


array = []
for index1 in range(h):
    row = []
    for index2 in range(w):
        row.append(0)
    array.append(row)



def populate( h, w, a, b, array):
    rowCounter = []
    columnCounter = []
    for index in range(h):
        rowCounter.append(0)
    for index in range(w):
        columnCounter.append(0)

    for rowIndex in range(h):
        for colIndex in range(w):
            
            if ((rowCounter[rowIndex] < a or w  - rowCounter[rowIndex] > a) and (columnCounter[colIndex] < b or h - columnCounter[colIndex] > b)):
                array[rowIndex][colIndex] = 1
                rowCounter[rowIndex] += 1
                columnCounter[colIndex] += 1

    for element in rowCounter:
        if (min(element, w - element) != a):
            return -1
    for element in columnCounter:
        if (min(element, h - element) != b):
        
            return -1
    return array

def display(array):
    if (array == -1):
        print("-1")
        pass
    else:
        strings = []
        for row in array:
            string = ""
            for index in range(len(row)):
                if (index != len(row) - 1):
                    string += str(row[index])
                else:
                    string += str(row[index])
            strings.append(string)
        for element in strings:
            print(element)

"""
for h in range(1, 30):
    for w in range(1,30):
        for a in range(0, math.floor(w/2) + 1):
            for b in range(0, math.floor(h/2)+1):
                array = []
                for index1 in range(h):
                    row = []
                    for index2 in range(w):
                        row.append(0)
                    array.append(row)
                if (populate(h, w, a, b, array) == -1):
                    print(h,w,a,b)
"""

display(populate(h, w, a, b, array))

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

arow = '1'*A + '0'*(W-A)
brow = '0'*A + '1'*(W-A)

for i in range(1,H+1):
    if (i <= B):
        print(brow)
    else:
        print(arow)

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 = [int(x) for x in input().split()]

def formatMatrix(matrix):
  return "\n".join(["".join(x) for x in matrix])

def bitShift(matrix, n):
  for i in range(len(matrix)):
    matrix[i] = shift(matrix[i], n)
  return matrix

def shift(row, n):
  new = [0]*len(row)
  i = 0
  carry = False
  for x in row:
    
    if (i+n) > n:
      carry = True
    new[(i+n)%len(row)] = x
    i +=1 
  
  if carry:
    for i in range((i+n)%len(row), len(row)):
      new[i] = '1'
  return new

def usualMatrix(n):
  i = 0
  x = []
  for a in range(n):
    x.append([])
    j = 0
    for y in range(n):
      if i == j:
        x[i].append('1')
      else:
        x[i].append('0')
      j += 1
    i += 1
  return x

def transpose(m):
  new = [[] for x in range(len(m[0])) ]
  for row in m:
    i = 0
    for entry in row:
      new[i].append(entry)
      i += 1
  return new

def thing(H,W,A,B):
  if H == W and A == 1 and B == 1:
    return usualMatrix(H)
  if H == 0 or W == 0:
    return -5
  if (B > H//2 or B < 0) or (A > W//2 or A < 0):
    return -1
  if B > A:
    a = thing1(W,H,B,A)
    if type(a) == int:
      return -1
    return transpose(a)  
  else:
    return thing1(H,W,A,B)
    
def thing1(H,W,A,B):
  matrix = [['1']*A+['0']*(W-A) for x in range(H)]
  part1 = bitShift(matrix[:B], A)
  part2 = matrix[B:]
  new_matrix = part1 + part2
  return new_matrix

matrix = thing(H,W,A,B)
if type(matrix) == int:
  print(-1)
else:
  print(formatMatrix(matrix))

Solution (Python):







H, W, A, B = map(int, input().split())
base = '0' * A + '1' * (W - A)
fliped = '1' * A + '0' * (W - A)

for _ in range(B):
    print(base)
for _ in range(H - B):
    print(fliped)

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

Solution (Python):

import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    
    H,W,A,B = LMIIS()
    l1 = '0'*A + '1'*(W-A)
    l2 = '1'*A + '0'*(W-A)
    for i in range(B):
        print(l1)
    for i in range(H-B):
        print(l2)
        

if __name__ == '__main__':
    main()

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

h, w, a, b = map(int, readline().split())
ans_1 = '1' * a + '0' * (w - a)
ans_2 = '0' * a + '1' * (w - a)
for i in range(b):
    print(ans_1)
for i in range(h - b):
    print(ans_2)

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return "".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


a = l()

dp = [[0 for i in range(a[1])] for j in range(a[0])]

for i in range(a[0]):
    po = 0
    if i > a[3]-1:
        po = 1

    for j in range(a[1]):
        ppo = po
        if j > a[2] - 1:
            ppo ^= 1
        dp[i][j] = ppo
for i in range(a[0]):
    print(jo(dp[i]))

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

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

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

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

Solution (Python):
def main():
    height, width, w_min, h_min = map(int, input().split())
    answer = [["1" for _ in range(width)] for _ in range(height)]
    for i in range(height):
        for j in range(width):
            if (i < h_min and j < w_min) or (h_min <= i and w_min <= j):
                answer[i][j] = "0"
    for i in range(height):
        print("".join(answer[i]))


if __name__ == '__main__':
    main()

Solution (Python):
H, W, A, B = map(int, input().split())
ans = [[0] * W for i in range(H)]
for i in range(A):
	for j in range(B):
		ans[j][i] = 1
i = A
while i < W:
	j = B
	while j < H:
		ans[j][i] = 1
		j += 1
	i += 1
for i in ans:
	for j in i:
		print(j, end='')
	print()

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

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

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

for i in range(h):
    if i < b:
        print('0' * a, end='')
        print('1' * (w-a))
    else:
        print('1' * a, end='')
        print('0' * (w-a))

Solution (Python):
def main():
    H, W, A, B = map(int, input().split())
    l1 = [0]*A + [1]*(W-A)
    l2 = [1]*A + [0]*(W-A)
    s1 = ''.join(map(str, l1))
    s2 = ''.join(map(str, l2))
    for i in range(B):
        print(s1)
    for i in range(B, H):
        print(s2)

if __name__ == '__main__':
    main()

Solution (Python):
H, W, A, B = map(int, input().split())
board1 = [[0] * A + [1] * (W - A) for _ in range(B)]
for l in board1:
    print(*l, sep='')
board2 = [[1] * A + [0] * (W - A) for _ in range(H - B)]
for l in board2:
    print(*l, sep='')

Solution (Python):


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








row1 = "1" * max(A, W-A) + "0" * min(A,W-A)
row2 = "0" * max(A, W-A) + "1" * min(A,W-A)
for i in range(max(B,H-B)):
    print(row1)
for i in range(min(B,H-B)):
    print(row2)

Solution (Python):
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True 
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

h,w,a,b = inm()
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):
import numpy
h, w, a, b = map(int,input().split())
s = numpy.zeros([h,w],int)
for i in range(h):
    ans = []
    for j in range(w):
        if i < b and j < a:
            ans.append("1")
        elif i < b and a <= j:
            ans.append("0")
        elif b <= i and j < a:
            ans.append("0")
        else:
            ans.append("1")
    print("".join(ans))

Solution (Python):


























h, w, a, b = list(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):
H, W, A, B = map(int,input().split())

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

h,w,a,b = MAP()
if a > w // 2 or b > h // 2:
    print('No')
    exit()
ans = [['0' for _ in range(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):
            ans[i][j] = '1'
for i in range(h):
    print(''.join(ans[i]))

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

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

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

h,w,a,b = na()
ans = []

for i in range(h):
    a = min(a,w-a)
    k = '0'*a + '1'*(w-a) if i < b else '1'*a+'0'*(w-a)
    ans.append(k)

print(*ans, sep='\n')

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):
  if i + 1 <= B:
    ans[i][A:] = ["1"] * (W-A)
  else:
    ans[i][:A] = ["1"] * A

for j in ans:
  print("".join(j))

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    H, W, A, B = map(int, input().split())
    S = [[None] * W for _ in range(H)]
    for h in range(B):
        for w in range(A): S[h][w] = 0
        for w in range(A, W): S[h][w] = 1
    for h in range(B, H):
        for w in range(A): S[h][w] = 1
        for w in range(A, W): S[h][w] = 0
    for h in range(H):
        print("".join(map(str, S[h])))

    return 0

if __name__ == "__main__":
    solve()

Solution (Python):



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

for i in range(1, H+1):
    for j in range(1, W+1):
        if i<=B and j<=A:
            print('0', end="")
        elif i<=B and j>A:
            print('1', end="")
        elif i>B and j<=A:
            print('1', end="")
        elif i>B and j>A:
            print('0', end="")
    print()

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

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

Solution (Python):
H, W, A, B = map(int, input().split())
ans = []
for i in range(H):
    if i < B:
       row = [1] * A
       row.extend([0] * (W - A))
    else:
        row = [0] * A
        row.extend([1] * (W - A))
    ans.append(row)
for row in ans:
    print(*row, sep='')

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

Solution (Python):

import sys
input = sys.stdin.readline

h, w, a, b = map(int, input().split())
if a > w // 2 or b > h // 2:
    print("No")
    exit()
ans = [[0] * w for _ in range(h)]
for i in range(0, b):
    for j in range(0, a):
        ans[i][j] = 1
for i in range(b, h):
    for j in range(a, w):
        ans[i][j] = 1
for line in ans:
    print("".join([str(item) for item in line]))

Solution (Python):
H, W, A, B = map(int, input().split())
ret = [[0] * W for _ in range(H)]
for h in range(H):
    for w in range(W):
        if w < A and h < B:
            ret[h][w] = 1
        elif w >= A and h >= B:
            ret[h][w] = 1

for row in ret:
    print(''.join([str(i) for i in row]))

Solution (Python):
H,W,A,B = map(int,input().split())
ans = []
for i in range(B):
    a = min(A,W-A)
    ans.append('0'*a + '1'*(W-a))
for i in range(H-B):
    a = min(A,W-A)
    ans.append('1'*a + '0'*(W-a))
print(*ans, sep='\n')

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())

L = ''.join(['1'] * A + ['0'] * (W - A))
R = ''.join(['0'] * A + ['1'] * (W - A))

ans = []
for h in range(H):
    if h < B:
        ans.append(L)
    else:
        ans.append(R)

print(*ans, sep='\n')

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

for i in range(b):
    ans = '0'*a + '1'*(w-a)
    print(ans)
for i in range(h-b):
    ans = '1'*a + '0'*(w-a)
    print(ans)

Solution (Python):
h,w,a,b=map(int,input().split())
for i in range(h):
    if i<b:
        print("1"*a+"0"*(w-a))
    else:
        print("0"*a+"1"*(w-a))
'''
行と列のそれぞれに注目して考えると、条件を満たすものであればそれぞれを入れ替えても条件を満たす(自分の都合のいいように行列を作ることができる)
↓
また、条件を満たすものであれば0と1を入れ替えても条件を満たす(0の個数にまずは注目して考える)
↓
入れ替えていってまずは行列を最終的には下のような形にすることができる
'''

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

ans = [['0']*w for i in range(h)]
for y in range(h):
    for x in range(w):
        if x<a and y<b:
            ans[y][x]="1"
        elif x>=a and y>=b:
            ans[y][x]="1"

for a in ans:
    print("".join(a))

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

Solution (Python):
H, W, A, B = map(int, input().split())
ans = [[0] * W for _ in range(H)]
row = [W-A] * H
column = [H-B] * W
for h in range(H):
    for w in range(W):
        if row[h] == 0:
            pass
        elif column[w] == 0 :
            pass
        else:
            ans[h][w] = 1
            row[h] -= 1
            column[w] -= 1

for row in ans:
    print(*row, sep="")

Solution (Python):



def main():
  h, w, a, b = map(int, input().split())
  for i in range(h):
    if i < b:
      print('0'*a+'1'*(w-a))
    else:
      print('1'*a+'0'*(w-a))
  
    

if __name__=='__main__':
  main()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W, A, B = MAP()

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

Solution (Python):
h,w,a,b = [int(x) for x in input().split()]
for i in range(h):
  if i<h-b:
    z = "0"*a
    o = "1"*(w-a)
    print(z+o)
  else:
    z = "0"*(w-a)
    o = "1"*a
    print(o+z)

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

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

for i in range(H-B):
  row = '0'*A+'1'*(W-A)
  ans.append(row)

print(*ans,sep='\n')

Solution (Python):
import sys
INF = 10 ** 9
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)

def main(): 
    h,w,a,b = map(int,input().split())
    grid = [['0']*w for _ in range(h)]

    if a == 0:
        for i in range(b):
            grid[i] = ['1'] * w

    elif b == 0:
        for i in range(h):
            for j in range(a):
                grid[i][j] = '1'
                
    else:
        for i in range(b):
            for j in range(a):
                grid[i][j] = '1'
            for j in range(2*a,w):
                grid[i][j] = '1'
        
        for i in range(b,2*b):
            for j in range(a,2*a):
                grid[i][j] = '1'
        
        for i in range(2*b,h):
            for j in range(a):
                grid[i][j] = '1'
    
    for i in range(h):
        print(''.join(grid[i]))  
    
if __name__=='__main__':
    main()

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

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

Solution (Python):
H, W, A, B = map(int,input().split())
S = [1] * A + [0] * (W - A)
T = [0] * A + [1] * (W - A)
s = ""
t = ""
for a in S:
    s += str(a)
for b in T:
    t += str(b)
for _ in range(B):
    print(s)
for _ in range(H - B):
    print(t)

Solution (Python):
h,w,a,b=map(int,input().split())
l=[[0 if i<a else 1 for i in range(w)]if j<b else [0 if i>=a else 1 for i in range(w)]for j in range(h) ]
for i in l:
    print("".join(map(str,i)))

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

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

for i in range(H):
  for j in range(W):
    if i < B and j < A or i >= B and j >= A:
      print(0, end="")
    else:
      print(1, end="")
  print("")

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

Solution (Python):
miis=lambda:map(int,input().split())

h,w,a,b=miis()
ans=[]
for i in range(b):
  ans.append(['1']*a+['0']*(w-a))
for i in range(h-b):
  ans.append(['0']*a+['1']*(w-a))
for i in ans:
  print(''.join(i))

Solution (Python):
def main():
    H, W, A, B = (int(i) for i in 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))


if __name__ == '__main__':
    main()

Solution (Python):

H, W, A, B = map(int, input().split(' '))
row1 = [1 for _ in range(A)] + [0 for _ in range(W-A)]
row2 = [0 for _ in range(A)] + [1 for _ in range(W-A)]

table = [list(row1) for _ in range(B)] + [list(row2) for _ in range(H - B)]
for row in table:
    print(''.join(map(str, row)))

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

for i in range(h):
    ans = []
    for j in range(w):
        ans.append(str((1 if i<b else 0)^(1 if j<a else 0)))
    print("".join(ans))

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

ans = []
for i in range(h):
    tmp = []
    for j in range(w):
        tmp.append(str((1 if i<b else 0)^(1 if j<a else 0)))
    ans.append(tmp)

for l in ans:
    print("".join(l))

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

ans = []
for i in range(h):
    tmp = []
    if i < b:
        x = 0
    else:
        x = 1
    for j in range(w):
        if j < a:
            y = 0
            tmp.append(str(x^y))
        else:
            y = 1
            tmp.append(str(x^y))
    ans.append(tmp)

for l in ans:
    print("".join(l))

Solution (Python):
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

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

def main():
  h,w,a,b=LI()
  field=[[0]*w for _ in range(h)]

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

  for i in range(b,h):
    for j in range(a,w):
      field[i][j]=1

  for x in field:
    print(''.join([str(y) for y in x]))

main()

Solution (Python):
H,W,A,B=map(int,input().split())
X=[0]*A+[1]*(W-A)
Y=[1]*A+[0]*(W-A)
for i in range(B):
  print(*X,sep='')
for i in range(H-B):
  print(*Y,sep='')

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

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

for i in range(H):
    row = []
    for j in range(W):
        if ((i < B and j < A) or (B <= i and A <= j)):
            row.append('0')
        else:
            row.append('1')
    print(''.join(row))

Solution (Python):
H,W,A,B=map(int, input().split())
S=["0"*A+"1"*(W-A)]*B+["1"*A+"0"*(W-A)]*(H-B)
print(*S, sep="\n")

Solution (Python):
H, W, A, B = map(int, input().split())
ans = []
for h in range(H):
    tmp = ""
    for w in range(W):
        if h < B:
            if w < A:
                tmp += "0"
            else:
                tmp += "1"
        else:
            if w < A:
                tmp += "1"
            else:
                tmp += "0"
    ans.append(tmp)
print("\n".join(ans))

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

for i in range(b):
    for j in range(a):
        li[i][j] = 1
for i in range(b,h):
    for j in range(a,w):
        li[i][j] = 1

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

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