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

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

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

e.w = d
d.r = i
m.w = d
h.w = i
b.w = d
i.r = d
l.w = i
assert i.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

e.w = d
d.r = i
m.w = d
h.w = i
b.w = d
i.r = d
l.w = i
assert i.r.r.r.txt == "d"