class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: B = None
        self.y: B = None
        self.txt = txt

e = A("e")
m = B("m")
n = A("n")
b = A("b")
d = A("d")
h = B("h")

e.w = m
m.x = h
m.y = h
n.w = h
b.w = h
d.w = m
h.x = m
h.y = m
assert b.w.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: B = None
        self.y: B = None
        self.txt = txt

e = A("e")
m = B("m")
n = A("n")
b = A("b")
d = A("d")
h = B("h")

e.w = m
m.x = h
m.y = h
n.w = h
b.w = h
d.w = m
h.x = m
h.y = m
assert b.w.y.y.y.y.txt == "h"