Buggy python submission (verdict: Runtime Error):
h, w, a, b = map(int, input().split())
mx = [[0 for i in range(w)] for _ in range(h)]
for k in range(a):
  mx[0][k] = 1

for i in range(b):
  mx[i][0] = 1

if w == 1 and a != 0:
  print("No")
elif w == 1 and a == 0:
  for j in range(h):
    s = [str(x) for x in mx[j]]
    print("".join(s))
elif h == 1 and b != 0:
  print("No")
elif h == 1 and b == 0:
  for j in range(h):
    s = [str(x) for x in mx[j]]
    print("".join(s))
else:
  pr = 1
  pc = 1

  while pr < w:
    for k in range(pc, pc + a - sum(mx[pr][:pc])):
      if k >= w:
        print("No")
        exit()
      else:
        mx[pr][k] = 1

    csum = 0
    for i in range(pr):
      csum += mx[i][pc]
    for i in range(pr, pr + b - csum):
      mx[i][pc] = 1
    pr += 1
    if pc < w - 1:
      pc += 1

  flg = 0
  for j in range(w):
    bsum = sum(mx[:][j])
    if min(bsum, h - bsum) != b:
      flg = 1
      break

  if flg == 1:
    print("No")
  else:
    for j in range(h):
      s = [str(x) for x in mx[j]]
      print("".join(s))

Fixed submission:
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))

Buggy python submission (verdict: Runtime Error):
h, w, a, b = map(int, input().split())
mx = [[0 for i in range(w)] for _ in range(h)]
for k in range(a):
  mx[0][k] = 1

for i in range(b):
  mx[i][0] = 1

if w == 1 and a != 0:
  print("No")
elif w == 1 and a == 0:
  for j in range(h):
    s = [str(x) for x in mx[j]]
    print("".join(s))
elif h == 1 and b != 0:
  print("No")
elif h == 1 and b == 0:
  for j in range(h):
    s = [str(x) for x in mx[j]]
    print("".join(s))
else:
  pr = 1
  pc = 1

  while pr < w:
    print(pr, pc, mx)
    for k in range(pc, pc + a - sum(mx[pr][:pc])):
      mx[pr][k] = 1

    csum = 0
    for i in range(pr):
      csum += mx[i][pc]
    for i in range(pr, pr + b - csum):
      mx[i][pc] = 1
    pr += 1
    pc += 1

  flg = 0
  for j in range(w):
    bsum = sum(mx[:][j])
    if min(bsum, h - bsum) != b:
      flg = 1
      break

  if flg == 1:
    print("No")
  else:
    for j in range(h):
      s = [str(x) for x in mx[j]]
      print("".join(s))

Fixed submission:
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))

Buggy python submission (verdict: Runtime Error):
import itertools

def main():
    h, w, a, b = map(int, input().split())
    mx_0 = [[1 if i < a else 0 for i in range(w)]]
    s01 = [1 if i < a else 0 for i in range(w)]
    ss = list(set(itertools.permutations(s01, w)))
    if a != w - a:
        s10 = [0 if i < a else 1 for i in range(w)]
        ss10 = list(set(itertools.permutations(s10, w)))
        ss.extend(ss10)

    mx01 = list(set(itertools.permutations(ss, h - 1)))
    for m in mx01:
        mx = mx_0.copy()
        mx.extend(m)
        flg = 1
        for i in range(w):
            b01 = [x[i] for x in mx]
            bsum = sum(b01)
            if min(bsum, h - bsum) != b:
                flg = 0
        if flg == 1:
            for j in range(h):
                s = [str(x) for x in mx[j]]
                print("".join(s))
            return

    print("No")
    return

main()

Fixed submission:
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))