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

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

class C:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

j = A("j")
d = B("d")
m = C("m")
e = B("e")
b = C("b")
f = C("f")
l = A("l")
h = C("h")

j.z = b
j.s = d
j.x = l
d.s = l
m.z = f
e.s = l
b.z = m
f.z = b
l.z = m
l.s = d
l.x = j
h.z = f
assert d.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.s: B = None
        self.x: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

j = A("j")
d = B("d")
m = C("m")
e = B("e")
b = C("b")
f = C("f")
l = A("l")
h = C("h")

j.z = b
j.s = d
j.x = l
d.s = l
m.z = f
e.s = l
b.z = m
f.z = b
l.z = m
l.s = d
l.x = j
h.z = f
assert d.s.s.s.s.txt == "d"