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

class B:
    def __init__(self, txt: str):
        self.s: B = None
        self.u: B = None
        self.txt = txt

m = A("m")
d = B("d")
b = A("b")
i = B("i")
e = A("e")
l = B("l")

m.y = i
d.s = i
d.u = i
b.y = l
i.s = l
i.u = l
e.y = d
l.s = d
l.u = d
assert m.y.s.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: B = None
        self.u: B = None
        self.txt = txt

m = A("m")
d = B("d")
b = A("b")
i = B("i")
e = A("e")
l = B("l")

m.y = i
d.s = i
d.u = i
b.y = l
i.s = l
i.u = l
e.y = d
l.s = d
l.u = d
assert m.y.s.u.txt == "d"