Buggy python submission (verdict: Runtime Error):
from fractions import Fraction

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


def search():
    for _ in range(b):
        print("0" * a + "1" * (w - a))
    for _ in range(b, H):
        print("1" * a + "0" * (w - a))
    return True


def solve():
    if a == 0 and b == 0:
        for _ in range(h):
            print("0" * w)
        return True
    if b == 0:
        for _ in range(h):
            print("0" * a + "1" * (w - a))
        return True
    if a == 0:
        for _ in range(b):
            print("0" * w)
        for _ in range(h - b):
            print("1" * w)
        return True
    if Fraction(w, h) == Fraction(a, b):
        for r in range(h):
            for c in range(w):
                if c // a == r // b:
                    print("1", end="")
                else:
                    print("0", end="")
            print()
        return True
    return search()


if not search():
    print("No")


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

Buggy python submission (verdict: Runtime Error):
from fractions import Fraction

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


def search():
    for _ in range(b):
        print("0" * a + "1" * (w - a))
    for _ in range(b, H):
        print("1" * a + "0" * (w - a))
    return True


def solve():
    if a == 0 and b == 0:
        for _ in range(h):
            print("0" * w)
        return True
    if b == 0:
        for _ in range(h):
            print("0" * a + "1" * (w - a))
        return True
    if a == 0:
        for _ in range(b):
            print("0" * w)
        for _ in range(h - b):
            print("1" * w)
        return True
    if Fraction(w, h) == Fraction(a, b):
        for r in range(h):
            for c in range(w):
                if c // a == r // b:
                    print("1", end="")
                else:
                    print("0", end="")
            print()
        return True
    return search()


if not solve():
    print("No")


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

Buggy python submission (verdict: Runtime Error):
from fractions import Fraction

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


def search(r, c):
    for _ in range(b):
        print("0" * a + "1" * (w - a))
    for _ in range(b, H):
        print("1" * a + "0" * (w - a))
    return True


def solve():
    if a == 0 and b == 0:
        for _ in range(h):
            print("0" * w)
        return True
    if b == 0:
        for _ in range(h):
            print("0" * a + "1" * (w - a))
        return True
    if a == 0:
        for _ in range(b):
            print("0" * w)
        for _ in range(h - b):
            print("1" * w)
        return True
    if Fraction(w, h) == Fraction(a, b):
        for r in range(h):
            for c in range(w):
                if c // a == r // b:
                    print("1", end="")
                else:
                    print("0", end="")
            print()
        return True
    return search()


if not solve():
    print("No")


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