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

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

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

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

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

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

l.s = j
j.y = d
m.y = j
b.s = m
i.s = j
e.s = j
f.s = m
d.y = m
c.s = j
assert d.y.y.y.txt == "d"