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

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

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

k = A("k")
h = B("h")
i = C("i")
j = C("j")

k.y = h
h.p = k
h.z = j
i.t = k
i.w = k
i.p = k
j.t = k
j.w = k
j.p = k
assert h.z.p.y.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

k = A("k")
h = B("h")
i = C("i")
j = C("j")

k.y = h
h.p = k
h.z = j
i.t = k
i.w = k
i.p = k
j.t = k
j.w = k
j.p = k
assert h.z.p.y.p.txt == "k"