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

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

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

a = A("a")
h = B("h")
l = C("l")
d = B("d")
f = A("f")

a.s = h
h.t = a
l.z = a
d.t = f
f.s = h
assert a.s.t.s.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

a = A("a")
h = B("h")
l = C("l")
d = B("d")
f = A("f")

a.s = h
h.t = a
l.z = a
d.t = f
f.s = h
assert a.s.t.s.t.s.txt == "h"