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

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

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

h = A("h")
c = B("c")
l = C("l")
f = B("f")
j = B("j")

h.u = l
h.t = c
c.z = f
l.p = f
f.z = j
j.z = f
assert f.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.t: B = None
        self.txt = txt

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

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

h = A("h")
c = B("c")
l = C("l")
f = B("f")
j = B("j")

h.u = l
h.t = c
c.z = f
l.p = f
f.z = j
j.z = f
assert f.z.z.z.z.z.txt == "j"