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

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

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

h = A("h")
j = B("j")
n = C("n")

h.z = n
j.r = h
n.y = j
n.v = h
n.t = h
assert h.z.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

h = A("h")
j = B("j")
n = C("n")

h.z = n
j.r = h
n.y = j
n.v = h
n.t = h
assert h.z.y.r.txt == "h"